Repository navigation
feat: recover Pages navigation across deployments - #897
Conversation
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "2dd6b067cde65cb86b7d14dd2f9dae0a196b86a6",
"result": {
"overallSummary": "A tab left open across a deploy imports chunks that no longer exist, so its next Pages navigation dies on the error boundary. This PR gives each build an id folded into both bundles, has the client send it and compare it against the response, and recovers a stale navigation with a single document load of the destination (query and fragment intact), with `deployRecovery: false` as the opt-out.",
"groups": [
{
"key": "build-identity-core",
"label": "Build identity and recovery",
"summary": "The heart of the change: derive one source-hash id per build, define it into both bundles, carry it on the wire, and let the server answer a GET from another build with the existing reload response while the client turns that into a document load of the destination.\n\nWorth extra care: the id must be identical in the client and server bundles, and the reload must fire at most once per destination.",
"category": "core",
"filePaths": [
"packages/edge/src/pages-protocol.ts",
"packages/edge/src/index.ts",
"packages/void/env.d.ts",
"packages/void/src/pages/build-id.ts",
"packages/void/src/pages/build-id-source.ts",
"packages/void/src/pages/plugin.ts",
"packages/void/src/pages/protocol.ts",
"packages/void/src/pages/navigation-engine.ts"
],
"critical": true,
"fileNotes": [
{
"path": "packages/void/src/pages/build-id-source.ts",
"text": "The cache is keyed on size + mtime rather than content, so the id is trusted whenever that fingerprint matches. The test documents the consequence: an edit that keeps the size and restores the mtime reuses the old id."
},
{
"path": "packages/void/src/pages/plugin.ts",
"text": "`buildId ??=` is computed once per plugin instance so both environment config resolutions agree; `userConfig.define` is spread *after* the computed define, which is what lets an app pin the id."
},
{
"path": "packages/void/src/pages/navigation-engine.ts",
"text": "Three separate guards here: the prefetch path drops a stale payload without reloading, only `method === 'GET'` may reload, and `claimDeployReload` allows one reload per (build, url) per 10s in `sessionStorage`. Removing any one of them reintroduces a bug the tests cover."
},
{
"path": "packages/void/src/pages/protocol.ts",
"text": "The build check is deliberately not in `Vary`: only the no-store reload response differs by build, and the payload body does not. A reviewer might expect a `Vary` here."
}
]
},
{
"key": "isr-build-scope",
"label": "ISR cache per build",
"summary": "Closes the hole the core change would otherwise leave: an ISR JSON cache hit skips the app entirely, so the reload response never happens. Cached payloads now keep the build that rendered them and are bypassed for a client from another build.",
"category": "data",
"filePaths": [
"packages/isr/src/runtime.ts"
],
"fileNotes": [
{
"path": "packages/isr/src/runtime.ts",
"text": "The build id is captured from the response header at populate time and replayed on the HIT; a client that sends no id still gets the cache (`isStaleBuild` returns false when nothing was seen)."
}
]
},
{
"key": "adapter-options",
"label": "Adapter option pass-through",
"summary": "Each framework plugin gains `deployRecovery` and now forwards its whole options object to the pages plugin instead of listing options one by one, so future pages-owned options need no per-adapter glue.",
"category": "build",
"filePaths": [
"packages/react/src/plugin.ts",
"packages/react/src/plugin-pages.ts",
"packages/solid/src/plugin.ts",
"packages/solid/src/plugin-pages.ts",
"packages/svelte/src/plugin.ts",
"packages/svelte/src/plugin-pages.ts",
"packages/vue/src/plugin.ts",
"packages/vue/src/plugin-pages.ts"
],
"fileNotes": [
{
"path": "packages/react/src/plugin.ts",
"text": "The spread now forwards every adapter option (including `react`, plus the new `deployRecovery`) into `pagesPlugin`; check that no option the pages plugin does not own starts colliding."
}
]
},
{
"key": "docs",
"label": "Recovery docs",
"summary": "Documents the deploy behaviour under Pages routing and lists `deployRecovery` in each framework's option reference.",
"category": "docs",
"filePaths": [
"docs/guide/pages-routing/overview.md",
"docs/reference/api/pages.md"
]
},
{
"key": "tests",
"label": "Tests",
"summary": "Covers build-id derivation and caching, the dev/opt-out no-op cases, the server reload response vs. matching build vs. stale mutation, the client reload/prefetch/dedupe paths, and the ISR bypass.",
"category": "tests",
"filePaths": [
"packages/void/test/unit/pages-build-id.test.ts",
"packages/void/test/unit/pages-client.test.ts",
"packages/void/test/unit/pages-protocol.test.ts",
"packages/void/test/unit/isr-cache.test.ts",
"packages/void/test/unit/pages-plugin-adapters.test.ts"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-22T03:26:23.220Z",
"model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
"locale": "en"
}
} |
|
Thanks! It looks like there are a few issues still. Here is a slop review:
|
A tab that outlives a deployment imports chunks that no longer exist. The loader answers it with the new build's props, the component import 404s, and the navigation dies on an error boundary or on the detached error page. Each build now gets one id, folded into both bundles. A Pages GET carries it, every Pages response names the build that answered, and a request from another build gets the reload response the protocol upgrade path already uses. The tab loads the destination as a document, keeping its query and fragment. Adapter plugins accept `deployRecovery: false` to keep their own error boundaries in charge.
A cached JSON payload now carries the build that rendered it, and a request from another build skips the entry so the app can answer with its reload response.
A stale navigation reloaded again when the reload response itself came back from the old build, since that response skips the page-data branch where the guard lives. The tab now stops on the recovery page instead. ISR deleted the shared HTML entry when a stale client's reload response looked uncacheable, and trusted cached payloads that named no build. Both paths now answer from the app and keep the entry. The build id hashed source files only, so builds that differed in `VITE_` env or `define` values shared an id while emitting different chunks. Both are part of the id now.
ISR never stored a build with its JSON entries, because the HTML document it copies them from carried none. Every client that names its build skipped the JSON cache. The document now names its build, and hosted dispatch keeps it. Hosted dispatch deleted a valid JSON entry when a stale tab asked for it, and stopped evicting shared HTML for any Pages request rather than only for the reload response. Both now match native ISR. A refresh or back/forward visit to a URL with a fragment only scrolled instead of loading the document, then showed the error page on the next try. Every same-origin fallback to a document load now reloads in that case. The build id covered only the app folder, so a change in a workspace package or the lockfile kept the old id. It now also hashes the workspace packages the app depends on and the workspace lockfile, counts dot files that configure the build, and skips folders it cannot read. One id is kept per build, from the first config pass until buildApp ends, so a time-based define or a file written meanwhile cannot split the client and server ids. An app define of the id is left to Vite without hashing the tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dd2a3a3 to
dcfccf6
Compare
|
Rebased on main and pushed a follow-up commit (dcfccf6) that closes a few gaps found in review:
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcfccf6a7d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A visit that consumed a prefetch answered by another build reloaded without claiming the one-reload guard. When a cache kept serving the old document, each hover and click on that link reloaded the page again. The visit now claims the same guard as an ordinary navigation and stops on the recovery page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`envDir: false` only skips the .env files. Shell `VITE_` values still reach the client bundle, so they must still change the Pages build id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Status of each point in this review, on head 6d5c834:
Each point has a regression test that fails without its fix. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d5c834f65
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Void folds schema-declared `VITE_` values into the client whatever the app's `envPrefix`, so the build id now always reads that prefix too. A Yarn Plug'n'Play install has no node_modules links, so the build id missed the workspace packages an app depends on. It now resolves them the way the Node target does, through `findPnpApi`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 028af5893d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…n env A form POST that redirects comes back as the destination's GET answer, but the build check still saw the POST and let a stale payload through. It now runs after the redirect is applied, so only the mutation's own response is exempt. Vite also inlines MODE, BASE_URL and DEV/PROD into the client, so the build id now covers the mode, the configured base and NODE_ENV. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe70fd103f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The build check treated every redirected answer as a GET, so a stale tab lost the result of a POST that a 307 or 308 carried to another URL. The transport now reports the method that got the answer, and only a GET answer can reload. Defines under `environments.client` reach the client bundle too, so the build id covers them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2da65a8854
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Native and hosted ISR skipped evicting shared HTML for any Pages answer without page data, so a loader or middleware that answered with an explicit no-store 200 left the public copy in place. Only the reload answer to a client from another build is exempt now: no page data, and a build that differs from the one the client sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abc11183a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…s on reload Native ISR returned the app's answer straight away when a cached JSON entry belonged to another build, which skipped evicting shared copies for a no-store answer. It now falls through to the normal render path, like hosted dispatch, and still keeps the entry for clients of its own build. `URL.origin` is "null" for capacitor:// URLs, so a same-document reload inside a Capacitor app looked cross-origin and only scrolled. The reload check now uses the shared isSameOrigin helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aca8beec27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…apacitor Rendered HTML now names its build, so an island route's page for a client from another build looked like the reload answer, and a no-store render kept shared copies. The exemption now also requires the reload answer's plain-text shape. The guard page compared URL origins directly, which are "null" for capacitor:// URLs, so a stale retry inside a Capacitor app threw instead of showing it. It now uses the shared isSameOrigin helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a75e342240
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A pages plugin instance kept its own copy of the build id, so a second build through the same instance reused the first id after buildApp had ended the build. The shared per-build memo already gives every environment one id, so the local copy is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7cfaeb9964
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Closes #849
Description
A tab that outlives a deployment imports chunks that no longer exist. The loader answers it with the new build's props, the component import 404s, and the navigation dies on an error boundary or on the detached "Something went wrong" page.
The tab now notices that the server runs a different build and recovers with one document load of the destination it asked for. The query string and fragment survive, the current page stays visible until the load starts, and the failed import never happens.
deployRecovery: falseturns it off.Each build gets one id, folded into the client and the server bundle. Every Pages request carries it in
X-VoidPages-Build, and every response names the build that answered. A GET from another build gets the response the protocol upgrade path already uses: no page data,no-store, and the current build in the header.Three things never reload the tab:
Options
definevalues. One id per build, fixed at the first config passvoid deploywould need one sourceVary: X-VoidPages-BuildOne reload per destination per 10s, kept in
sessionStorage, guards against a cache that keeps serving the old document. Without storage the guard is inert and the reload still happens.The id covers the whole app folder and the workspace packages it uses, so a server-only deploy also reloads open tabs, once. Modules imported by a relative path from outside those are not seen. Hashing the client output would be exact, but those names exist only after the client build, and the Node target builds the server first. The breadth costs one extra document load on such a deploy. Hashing itself is cheap: about 1ms for a normal app, and the second pass over an 8000-file tree reuses the cached id in about 30ms.
Server-side comparison means the request carries a build and the response depends on it, without
Vary. Page data isno-store, so the responses that differ are already uncached. If the request shape should stay fixed, the client can compare the response header instead, at the costs above.Still open
Prerendered apps keep page props in
/_void/pages/*.json, which has no build id, so a stale tab on a prerendered page still lands on its error boundary.Rolling deployments compare ids exactly, without a retry. While two builds are live, a fresh tab can reload once more than it needed to. A retry would have to tell a rollout apart from a stale document, which the tab cannot see.
The id is built from the inputs that reach the client bundle, so an input it does not see keeps the old id. Known gaps, tracked as follow-ups:
env.tspublic defaults computed from variables without theVITE_prefix (resolved after the id is set)Deriving the id from the client build output would close all three. That is a larger change than this PR.
Test
Build identity: one id per build across environments, derived from the source, withheld in dev and when recovery is off.
Server: a GET from another build gets the reload response with the current id and no page data. A matching build gets the payload. A mutation from a stale client keeps its response.
Client: the visit reloads the destination with its query and fragment, a second visit renders instead, a prefetch drops a stale payload, a stale mutation response is applied, and a response with no build id is left alone.
ISR: an entry from another build is bypassed, a matching one is served with its id, and a client that sends no id still hits the cache.
Both captures use
playground/react-pagesand the same request:GET /withX-VoidPages: true,X-VoidPages-Version: 2andX-VoidPages-Build: 000000000000.Base
92a01567b:537 bytes of page props for a tab that cannot import them. This is the bug.
This branch:
An empty body, no
x-voidpages, and the live build, which is the reload the client performs. The same request carrying that id returns the 537-byte payload, header included, unchanged.Both bundles of that build inline
e599410d42d0. The per-build UUID this started with produced18ad6551…in one and5c7377c7…in the other.