fix(cdn): retry manifest fetch after transient download failure#2262
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(cdn): retry manifest fetch after transient download failure#2262cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
_lastUpdatedAt was advanced when lastUpdateTime.json reported a newer timestamp, even if the subsequent manifest download failed. That made later refresh checks skip the update until the CDN published again, leaving CDN-backed apps on stale definitions for the rest of the session. Only commit the remote timestamp after a manifest is successfully fetched and cached. Extract cdnShouldFetchManifest helpers for unit testing. 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.How to Test
modules/ensemble, runflutter test test/cdn_provider_test.dart.Duplicate check
listenForChangesdedup crash; different code path.cursor/critical-bug-remediation-c136) — CDN background lifecycle deferral for artifact refresh UI; different root cause (i18n refresh ordering on pause/resume, not failed-fetch retry)._lastUpdatedAtcommit on failed download._lastUpdatedAtadvancement on failed manifest fetch.Type of Change