mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #745] [MERGED] fix(navigation): track pending pathname to fix isSameRoute race condition during rapid navigation #813
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#813
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/745
Author: @Divkix
Created: 4/2/2026
Status: ✅ Merged
Merged: 4/13/2026
Merged by: @james-elicx
Base:
main← Head:fix/744-pending-pathname-race📝 Commits (10+)
78eefbffix(navigation): track pending pathname to fix isSameRoute race condition during rapid navigation76101bbfix(navigation): address review feedback on pending pathname race condition fix7056e6aresolve merge conflict5c9e3d6Resolve merge conflict: keep pending pathname race condition fix (#744)391a244Address PR review feedback for pending pathname race condition fix61734a1Fix unit tests - remove client-side mocks that fail in CI9287f4bFix formatting issues in tests/shims.test.ts3cbab5achore(tests): clarify smoke test comments for pending pathname helpersb35fc90fix: clear pending pathname when navigating to different route4f694b6fix: remove race condition in pending pathname handling📊 Changes
8 files changed (+298 additions, -18 deletions)
View changed files
📝
packages/vinext/src/server/app-browser-entry.ts(+48 -16)📝
packages/vinext/src/shims/navigation.ts(+53 -2)📝
tests/e2e/app-router/navigation-flows.spec.ts(+44 -0)➕
tests/e2e/app-router/rapid-navigation.spec.ts(+84 -0)➕
tests/fixtures/app-basic/app/nav-rapid/layout.tsx(+3 -0)➕
tests/fixtures/app-basic/app/nav-rapid/page-a/page.tsx(+26 -0)➕
tests/fixtures/app-basic/app/nav-rapid/page-b/page.tsx(+22 -0)➕
tests/fixtures/app-basic/app/nav-rapid/page-c/page.tsx(+18 -0)📄 Description
Fixes #744
Problem
During rapid successive navigations (e.g., user clicks A→B→C quickly), the "isSameRoute" check in app-browser-entry.ts compared against stale window.location.pathname because URL commits are deferred via useLayoutEffect.
Solution
Add pendingPathname to ClientNavigationState to track the destination URL of in-flight navigations. This allows isSameRoute to compare against the most recent pending destination instead of stale window.location.pathname.
Changes
Edge Cases Handled
Testing
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.