Repository navigation
fix(pages): keep the committed page when a history write fails - #598
Merged
Merged
Conversation
A navigation commit wrote history last. If pushState or replaceState threw (Safari's rate limit, a SecurityError), the new page had already taken over the head, scroll key and Deferred values while the address bar still showed the old URL, and the visit never went idle. Write history first in the engine commit, so a failed write leaves the committed page untouched and only disposes the new one. The core client (Vue, Svelte, Solid) and the React adapter then show the committed page again and end the visit. A same-page hash visit whose write fails now rejects through its shell instead of throwing synchronously. Fixes #562. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
@codex review |
Codex Review SummaryThis 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. |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-navigation-commit-failure-void-cloud.voidzero-docs.workers.dev (commit 14c7102)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #562.
A Pages navigation wrote history last. When
pushStateorreplaceStatethrew (Safari's rate limit, aSecurityError), the new page had already taken over, but the address bar still showed the old URL and the visit never went idle.What changed
The engine has to write first. Disposing the old page, handing over its Deferred values and updating the head can't be undone, so a rollback after the fact isn't possible.
Overlapping visits:
Kept as before: the #507 guard runs first, #506 (history for every visit that isn't back/forward), and #527/#566 (a same-URL form submission replaces its entry).
Tests
pages-client.test.ts, newfailed history writes (#562)block. It covers a failed push, a failed replace, a same-URL POST (form state kept), a working visit after a failure, an older visit failing while a newer one loads (the newer one commits, or fails too), a hash visit settling first, a failed hash visit, and the engine called the way React calls it (a secondcommit()is a no-op, and the old page still gets its streamed Deferred values).pages-scroll.test.ts: after a failed write, positions are saved under the current entry's key.react-pages-client.test.ts(browser): a Link push and areplaceLink whose write fails. The page stays, the URL stays, state goes idle, and the next click works.mainone at a time (engine, core client, the hash-visit-first branch, hash shell, scroll key, React adapter). Each one made a test fail.vp run check,vp lint,vp fmt,vp run testand one fullvp test runpass.Choices to check
useFormhas already reported success when the shell arrives, before the commit. If the write then fails, the form keeps its result, the page rolls back, and the error goes toreportErrorso it isn't dropped silently. MakinguseFormwait for the commit would change its timing for every submission.titleargument, so this shouldn't show.<Form>/Link don't catch a rejected visit, so a failed write there is an unhandled rejection (as with any other visit error today).🤖 Generated with Claude Code