Repository navigation
Rate-limit remote feature-flag and remote-config fetches - #26189
Open
feather2222 wants to merge 1 commit into
Open
feather2222 wants to merge 1 commit into
feather2222 wants to merge 1 commit into
Conversation
After the UIScene adoption (wordpress-mobile#25643), WordPressAppDelegate refreshes both stores on cold launch twice (willFinishLaunch + the foreground transition), and the stores themselves have no client-side throttle, so any caller asking twice in quick succession hits the network twice. Give each store a persisted last-fetched date and a 5-minute minimum refresh interval, shaped after AppUpdateCoordinator.shouldFetchAppStoreInfo: update() serves the cache (still invoking its callback) within the interval. A force: bypass keeps per-user flag refreshes working on account change/logout, and failed fetches don't stamp the date so retries aren't suppressed. Fixes wordpress-mobile#25665
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #25643: after the UIScene adoption,
WordPressAppDelegaterefreshes the remote stores in bothwillFinishLaunchingand the foreground transition that fires right after the first scene connect, soupdateFeatureFlags()/updateRemoteConfig()run twice on every cold launch.The deeper gap (per the issue): the stores have no client-side fetch throttle, so any caller asking twice in quick succession hits the network twice.
RemoteFeatureFlagStoreeven cancels the in-flight request and refetches;RemoteConfigStorejust fires again.Fix
Give each store a persisted last-fetched date and a 5-minute minimum refresh interval, shaped after the existing
AppUpdateCoordinator.shouldFetchAppStoreInfoprior art:update()within the interval serves the cache and still invokes its callback (callers' UI continuation behavior unchanged).force: truebypasses the limit — used byAccountHelperon logout and byupdateFeatureFlags(authToken:)when an explicit token is passed, since flags are customized per-user server-side (the caveat called out in the issue).minimumRefreshInterval) for testing.This subsumes the #25643 cold-launch double-fetch, so no one-off debounce in the AppDelegate is needed.
Tests
Added unit tests for both stores: skip-within-interval, forced refresh bypass, recent-fetch skip, fetch-after-interval, and retry-not-suppressed-after-failure. The existing double-fetch test in
RemoteFeatureFlagTestsnow passesminimumRefreshInterval: 0to preserve its original semantics.To test
update()from the foreground transition logs "Skipping … fetched recently" instead of hitting the network.RemoteFeatureFlagTests,RemoteConfigStoreRateLimitTests.Fixes #25665