Skip to content

fix(app-router): align navigation prefetch commits#2104

Open
NathanDrake2406 wants to merge 2 commits into
cloudflare:mainfrom
NathanDrake2406:nathan/navigation-upstream-parity
Open

fix(app-router): align navigation prefetch commits#2104
NathanDrake2406 wants to merge 2 commits into
cloudflare:mainfrom
NathanDrake2406:nathan/navigation-upstream-parity

Conversation

@NathanDrake2406

Copy link
Copy Markdown
Contributor

Summary

This ports the relevant behaviour from Next.js's test/e2e/app-dir/navigation/navigation.test.ts and fixes the App Router navigation lifecycle issues that surfaced in the deploy harness:

  • keep optimistic/loading-shell prefetch payloads out of final navigation consumption, even if a later Link prefetch attempts to promote the cache entry
  • omit destination metadata from loading-shell prefetch payloads so a prefetched loading boundary cannot update the document title before the real navigation content commits
  • render the final authoritative payload against the latest router state after the optimistic shell has mounted, avoiding stale-state no-ops
  • resolve same-path search+hash navigations when the visible tree is unchanged, so URL and hash-scroll side effects still complete
  • route App-to-Pages/document navigations through the App Router's MPA scheduler before falling back to a hard browser navigation

Upstream references

Test notes

The local Playwright port keeps the same observable contracts as the upstream file. The hash fixture uses the same link structure and RSC-request assertions; target scroll positions are computed from the rendered fixture because app-basic has a different root/template offset than Next.js's upstream fixture. The async metadata fixture preserves the 5s metadata delay and fallback/content/title assertions. The upstream deploy-suite run remains the exact file-scope parity check.

Verification

  • vp test run tests/app-browser-entry.test.ts -t "same-path search and hash|stays pending until NavigationCommitSignal|authoritative payload"
  • PLAYWRIGHT_PROJECT=app-router pnpm exec playwright test tests/e2e/app-router/nextjs-compat/navigation.spec.ts --grep "hash|navigating to a page with async metadata"
  • vp test run tests/app-page-route-wiring.test.ts tests/prefetch-cache.test.ts tests/app-browser-entry.test.ts tests/link-navigation.test.ts tests/link.test.ts tests/navigation-planner-prefetch-reuse.test.ts
  • vp check
  • vp env exec --node 24 ./scripts/run-nextjs-deploy-suite.sh /Users/nathan/Projects/vinext/.refs/nextjs-v16.2.6 --retries 0 -c 1 --debug test/e2e/app-dir/navigation/navigation.test.ts

@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2104
npm i https://pkg.pr.new/vinext@2104

commit: c4d132e

@NathanDrake2406 NathanDrake2406 marked this pull request as ready for review June 17, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant