Repository navigation
feat: recover Pages navigation across deployments #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Brooooooklyn
merged 14 commits into
voidzero-dev:main
from
0froq:feat/pages-deploy-recovery
Nov 26, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3005c8d
feat: recover Pages navigation across deployments
0froq 52a30a1
fix: serve ISR page data only to the build that rendered it
0froq f542f8b
fix: address Pages deploy recovery review findings
0froq dcfccf6
fix: close gaps in Pages deploy recovery
Brooooooklyn 71fea3f
fix: spend one reload on a stale prefetch too
Brooooooklyn 6d5c834
fix: keep shell env values in the build id when envDir is false
Brooooooklyn 028af58
fix: hash fixed-prefix client env and Plug'n'Play workspace packages
Brooooooklyn fe70fd1
fix: check the page a mutation redirected to, and hash Vite's built-i…
Brooooooklyn 2da65a8
fix: keep 307/308 mutation answers, and hash client environment defines
Brooooooklyn abc1118
fix: keep shared ISR eviction for ordinary Pages answers
Brooooooklyn aca8bee
fix: invalidate after an ISR build bypass, and match Capacitor origin…
Brooooooklyn a75e342
fix: match only the empty reload answer, and show the guard page in C…
Brooooooklyn 7cfaeb9
fix: drop the plugin-local build id so a reused plugin hashes again
Brooooooklyn f337b89
fix: skip deploy recovery for a visit a newer one replaced
Brooooooklyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,57 @@ | ||
| /** Current Pages wire version; a missing header identifies legacy clients. */ | ||
| export const PAGES_PROTOCOL_VERSION = '2'; | ||
|
|
||
| /** | ||
| * The build a request or response belongs to. Unlike the protocol version it | ||
| * changes with every deploy, so a tab that outlives a deployment can tell that | ||
| * the chunks it still holds are gone. | ||
| */ | ||
| export const PAGES_BUILD_HEADER = 'X-VoidPages-Build'; | ||
|
|
||
| /** | ||
| * Whether a build id seen on the wire belongs to another deployment. A peer | ||
| * that sends no id (an older Void, or a parse of a partial response) is not | ||
| * evidence of a new build, so it never counts as a mismatch. | ||
| */ | ||
| export function isStaleBuild(buildId: string, seen: string | null | undefined): boolean { | ||
| return buildId !== '' && typeof seen === 'string' && seen !== buildId; | ||
| } | ||
|
|
||
| /** Request and response headers that carry a build, empty when none is known. */ | ||
| export function buildHeaders(buildId: string): Record<string, string> { | ||
| return buildId === '' ? {} : { [PAGES_BUILD_HEADER]: buildId }; | ||
| } | ||
|
|
||
| /** | ||
| * Whether a cached Pages payload may answer a request. A client that names no | ||
| * build cannot tell builds apart, so it keeps the cached payload. A client that | ||
| * names one accepts only a payload from that same build, and an entry without an | ||
| * id predates ids, so it is not trusted either. | ||
| */ | ||
| export function pagesPayloadFitsBuild( | ||
| cachedBuild: string | null, | ||
| requestBuild: string | null, | ||
| ): boolean { | ||
| return requestBuild === null || cachedBuild === requestBuild; | ||
| } | ||
|
|
||
| /** | ||
| * Whether `response` is the app's reload answer to a Pages client from another | ||
| * build: an empty plain-text answer without page data, naming a build other than | ||
| * the one the client sent. A rendered page, such as an island route's HTML, is | ||
| * not one even when it names another build. The reload answer says nothing about | ||
| * cached copies of the page, which other tabs still use. | ||
| */ | ||
| export function isStaleBuildReload(request: Request, response: Response): boolean { | ||
| const sent = request.headers.get(PAGES_BUILD_HEADER); | ||
| const answered = response.headers.get(PAGES_BUILD_HEADER); | ||
| const type = (response.headers.get('Content-Type') ?? '').split(';', 1)[0]?.trim(); | ||
| return ( | ||
| request.headers.has('X-VoidPages') && | ||
| !response.headers.has('X-VoidPages') && | ||
| type === 'text/plain' && | ||
| sent !== null && | ||
| answered !== null && | ||
| sent !== answered | ||
| ); | ||
| } | ||
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /** | ||
| * Constants the build folds into both the client and server bundles, such as | ||
| * the Pages build id. Vite replaces each key at build time. | ||
| */ | ||
| interface ImportMeta { | ||
| readonly env: Record<string, unknown>; | ||
| } |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.