fix(cdn): defer lastUpdatedAt commit until manifest fetch succeeds#2284
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(cdn): defer lastUpdatedAt commit until manifest fetch succeeds#2284cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
When lastUpdateTime.json reports a newer timestamp but the manifest download fails, advancing _lastUpdatedAt before a successful fetch caused subsequent refresh checks to skip the download for the rest of the session. Evaluate freshness without mutating _lastUpdatedAt and commit the remote timestamp only after the manifest is parsed and cached. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
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.
Description
Fixes a CDN freshness bug where a successful
lastUpdateTime.jsoncheck could permanently skip manifest re-download for the rest of the app session if the actual manifest fetch failed.Bug and impact
Trigger: A CDN-backed app checks for updates;
lastUpdateTime.jsonreports a newerlastUpdatedAt, but the manifest download fails (network timeout, 5xx, decrypt error, etc.).Impact:
_lastUpdatedAtwas advanced before the manifest was successfully fetched and cached. Subsequent refresh checks saw matching timestamps and skipped the download until the CDN published another update. Apps could remain on stale screens, scripts, and translations for the entire session.Root cause
_shouldFetchManifest()mutated_lastUpdatedAtto the remote timestamp as soon aslastUpdateTime.jsonwas read, before_fetchManifest()completed. A failed download left the in-memory timestamp advanced with no corresponding cached manifest.Fix
_shouldFetchManifest()with_evaluateManifestFreshness()that returns{shouldFetch, remoteLastUpdatedAt}without mutating_lastUpdatedAt._commitRemoteLastUpdatedAt().cdnShouldFetchManifest/cdnIsIncomingManifestNewerhelpers for unit testing.Related Issue
Type of Change
What Has Changed
CdnDefinitionProvider._evaluateManifestFreshness()evaluates freshness without side effects._commitRemoteLastUpdatedAt()is called only after successful manifest parse/cache in_loadManifestand_doRefreshIfStale.How to Test
modules/ensemble, runflutter test test/cdn_provider_test.dart.Duplicate check
cursor/critical-bug-remediation-5d4b): FirestorelistenForChangesdedup crash — different code path.cursor/critical-bug-remediation-76ab): same root cause; was closed without merge and is not covered by any open PR.cursor/critical-bug-remediation-2ba3): CDN refresh serialization / persisted cache snapshot — different root cause._lastUpdatedAtcommit on failed download.Checklist
flutter analyzeand addressed any new warningsflutter testand all tests pass