Skip to content

Serve cached flags for a grace period after source failures - #508

Closed
luismeyer wants to merge 4 commits into
flags-version-headerfrom
codex/flags-runtime-freshness
Closed

luismeyer wants to merge 4 commits into
flags-version-headerfrom
codex/flags-runtime-freshness

Conversation

@luismeyer

@luismeyer luismeyer commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

When a stream disconnects or an update fails, keep serving the last accepted flag definitions for staleIfErrorMs after that first failure. A healthy stream can receive no new configuration all day and still get its full grace period when it disconnects.

The controller keeps its existing cache and one unhealthySince timestamp. Repeated failures leave the timestamp unchanged; accepted updates and successful confirmations clear it. Streaming and polling reads only inspect the cache and grace period, without triggering extra polls or waiting for reconnection. After grace expires, evaluations use supplied defaults or throw, and getDatafile() throws.

Stacked on #498, targeting flags-version-header at ea4d7de63567a232c27295ff048541c65b644530.

  • staleIfErrorMs defaults to Infinity; finite values measure milliseconds from the first failure/disconnect, and zero disables error fallback. Grace does not depend on fetchedAt or extend SWR. Provided/bundled definitions qualify even without a timestamp.
  • Header-specific staleWhileRevalidateMs retains its 10,000 ms default. Header reads share transport and background handling, validate each request's required version, and use the same error grace after a refresh failure. A satisfied reader is independent of a concurrent reader's version failure.
  • Unchanged stream/poll confirmations and primed messages clear an outage without replacing data. Rejected versions do not. Polling continues on its existing interval after initialization failures. Shutdown ignores late arrivals.
  • Build/offline caches remain static. Initialization still hydrates provided/bundled data before selecting Vercel mode, including concurrent cold reads.

Validation: 637 core tests across 17 files (live integration tests excluded), including 27 outage-grace public-API cases; 24 embedding tests; both package type checks; Biome for changed TypeScript and git diff --check. Reviewed grace boundaries, repeated failures, recovery, concurrency and shutdown; no remaining substantive findings.

Remaining transport limits: no automatic header catch-up/retry loop; later requests can retry. Stream reconnection stays in the existing transport, and cancellation depends on transport settlement. No new retry/backoff/deadline machinery is introduced.

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC
flags-sdk-dev Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC
shirt-shop Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC
shirt-shop-api Ready Ready Preview, v0 Sep 22, 2026 2:12pm UTC

This branch was successfully deployed

6 active deployments
Preview – flags-sdk-dev — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
Preview – flags-playground — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
Preview – shirt-shop-api — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
Preview – shirt-shop — 479522d0 Deployed Sep 22, 2026 by vercel[bot]
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