Repository navigation
fix(app-router): align navigation prefetch commits - #2104
NathanDrake2406 wants to merge 7 commits into
Conversation
commit: |
# Conflicts: # packages/vinext/src/server/app-page-element-builder.ts # packages/vinext/src/shims/link.tsx
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
# Conflicts: # packages/vinext/src/server/app-browser-entry.ts # packages/vinext/src/server/app-browser-navigation-controller.ts # packages/vinext/src/server/app-browser-state.ts
|
Mapping this PR to App/Pages functional failures from run 28478866791 / job 84413308650: test/e2e/app-dir/navigation/navigation.test.ts — app dir - navigation > navigating to a page with async metadata > shows a fallback when prefetch completed. This looks like it covers those backlog rows, so I'm not opening a duplicate fix. |
# Conflicts: # packages/vinext/src/shims/navigation.ts # tests/prefetch-cache.test.ts
|
This maps to three remaining functional rows from compatibility run 29871622126 / job 88775791401 in I re-ran the exact targeted Next.js v16.2.6 suite on the current-main campaign baseline ( |
|
I refreshed the currently failing functional subset against main in a scoped same-repo replacement: #2669. The exact |
…ream merge Upstream now owns both behaviors this branch previously patched: - createPendingNavigationCommit baselines on the navigation initiation state (cloudflare#2609), which is what lets an authoritative payload replace a stale cross-param optimistic layout. The payload-ready live re-read re-introduced exactly that staleness, so the currentStateTiming / getCurrentStateAfterElementsReady plumbing is removed. - Loading-shell prefetch responses intentionally stream generated metadata so rewrites can reuse it without a second request (cloudflare#2455, cloudflare#2318). Stripping resolvedMetadata / streamingMetadata from shell renders broke that protocol; the element-builder now matches upstream. Keeping shell payloads out of navigation consumption remains handled client-side via isPrefetchCacheEntryConsumableForNavigation. Tests asserting the old behaviors are removed or aligned with the upstream contract (authoritative commits declare navigationCommitKind).
Summary
This ports the relevant behaviour from Next.js's
test/e2e/app-dir/navigation/navigation.test.tsand fixes the App Router navigation lifecycle issues that surfaced in the deploy harness:Upstream references
PrefetchKind.AUTO/FULLsemantics: https://github.com/vercel/next.js/blob/ee6e79b1792a4d401ddf2480f40a83549fe8e722/packages/next/src/client/components/router-reducer/router-reducer-types.ts#L131-L146Test 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-basichas 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.tsvp checkvp 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