Skip to content

Add server-managed stale client handling with build IDs#1222

Draft
justinvdm wants to merge 7 commits into
mainfrom
stale-build-ids
Draft

Add server-managed stale client handling with build IDs#1222
justinvdm wants to merge 7 commits into
mainfrom
stale-build-ids

Conversation

@justinvdm

Copy link
Copy Markdown
Collaborator

Problem

Stale RedwoodSDK tabs keep talking to a newer deployment without any framework-managed version check. Core RSC requests continue to succeed when they should tell the client to reload, and synced state websocket sessions continue to open against a newer build.

Solution

We generate a RedwoodSDK build ID through the Vite plugin, expose it to the worker and client runtime, and use it as the shared stale version signal. Core requests now send their client build ID, synced state websocket URLs carry the same version, asset URLs include the build ID, and the server returns a reload response when an older client talks to a newer build. We also added permanent deploy-only playground coverage for the core stale request path and the synced state stale session path.

Verification

We ran the focused stale unit tests and both deploy-only playground stale tests in preview mode. All passed.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploying redwood-sdk-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 730eae2
Status: ✅  Deploy successful!
Preview URL: https://09dadfb9.redwood-sdk-docs.pages.dev
Branch Preview URL: https://stale-build-ids.redwood-sdk-docs.pages.dev

View logs

… check

Replace handleStaleResponse (check + act) with pure isStaleReloadResponse.

Remove triggerStaleReload, clearStaleReloadGuard, and sessionStorage state.

A stale reload is a full page load that always fetches fresh HTML and assets.

The new client bundle has no stale state, so a guard is unnecessary.
Lift await fetchPromise before handleResponse branch so stale check runs once.

Remove stale check from navigation.ts handleResponse; stale is handled upstream.
- Rename getStaleEvent → isStaleRequest (boolean predicate)

- Add buildStaleEvent for custom policies that need event data

- Rename withClientVersionQuery → addClientVersionToUrl

- Remove dead withClientVersionQueryString wrapper

- Extract createClientVersionHeaders for DRY header building

- Add docs/architecture/staleClientHandling.md
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