Skip to content

fix(cdn): retry manifest fetch after transient download failure#2262

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-76ab
Draft

fix(cdn): retry manifest fetch after transient download failure#2262
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-76ab

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Jun 6, 2026

Description

Fixes a CDN freshness bug where a successful lastUpdateTime.json check 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.json reports a newer lastUpdatedAt, but the manifest download fails (network timeout, 5xx, decrypt error, etc.).

Impact: _lastUpdatedAt was 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 _lastUpdatedAt to the remote timestamp as soon as lastUpdateTime.json was read, before _fetchManifest() completed. A failed download left the in-memory timestamp advanced with no corresponding cached manifest.

Fix

  • Replace _shouldFetchManifest() with _evaluateManifestFreshness() that returns {shouldFetch, remoteLastUpdatedAt} without mutating _lastUpdatedAt.
  • Commit the remote timestamp only after a manifest is successfully parsed and cached via _commitRemoteLastUpdatedAt().
  • Extract cdnShouldFetchManifest / cdnIsIncomingManifestNewer helpers for unit testing.

How to Test

  1. From modules/ensemble, run flutter test test/cdn_provider_test.dart.
  2. All 11 tests pass, including new coverage for freshness evaluation and deferred timestamp commit.

Duplicate check

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
Open in Web View Automation 

_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant