Repository navigation
Conversation
A blocker answer can arrive after a newer popstate or an accepted push or replace has replaced it. A late "stay" still ran go(-delta). With no popstate coming back, ignoreNextPop stayed set and ate the next Back. With one, the browser landed on the wrong entry. Drop the answer in that case. Also skip the restore when delta is 0 or NaN, because go(0) and go(NaN) reload the document and dropping a late answer sends one more sequence there. This does not fix index drift after a push during a blocked traversal, so answering "stay" to the next question can still leave the URL and router apart. Test: @tanstack/history unit, types and ESLint; history-blocking.spec.ts in Chromium, Firefox and WebKit Bug: TanStack#8878 Signed-off-by: Carlos Galo <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
🦋 Changeset detectedLatest commit: fbfc8db The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
agammann
left a comment
There was a problem hiding this comment.
I checked the new stale-answer guard against the unit and browser tests. The pop counter covers a newer traversal even if it reaches the same entry, while the location identity check covers an accepted push or replace with no intervening popstate. The zero/NaN delta cases also have explicit no-reload coverage, including an end-to-end draft-value assertion. The known index-drift case after a push remains open as described in the PR. This review was drafted with AI assistance from the diff; I did not run tests locally.
🎯 Changes
Refs #8878
Also see #8895, which targets the same issue. I left a note there on one case where it reloads the page.
Ignore a blocker answer once a newer popstate, or an accepted push/replace, has superseded it. On main a late "stay" still calls
go(-delta). When no popstate comes back,ignoreNextPopstays set and eats the next Back. When one does, the browser lands on the wrong entry.Also skip the restore when the traversal has no index difference (
deltais 0 or NaN).go(0)andgo(NaN)reload the document, and dropping late answers adds one more way to reach them (Forward waits, push, Back, stay). The tradeoff: a "stay" on such a traversal now keeps the document but leaves URL and router apart, where main reloads.In the #8878 reproducer, the second Back now reaches the blocker, which is still mounted and asks again. While it waits, URL is
/firstand router is/new. Leaving puts both on/first. Staying still leaves them apart: the push stored index 3 at position 2, sogo(+2)is out of range andignoreNextPopstays set. That index drift is not addressed here, and #8847 does not change it.Apps that wait for a restore popstate after answering an obsolete blocker will no longer get one.
Test: 13 unit cases and the first e2e case fail on main
Test: history-blocking e2e in Chromium, Firefox and WebKit
Merges cleanly with #8492 and #8847. Bundle: +12 to +50 B gzip across the 18 scenarios.
AI disclosure: code, tests and this description were drafted with AI (Claude). I reviewed them.
✅ Checklist
🚀 Release Impact
🤖 Generated with Claude Code
Summary by CodeRabbit