fix(app-router): reuse metadata rewrite prefetches - #2455
Conversation
|
/bigbonk review for issues |
commit: |
|
Review: reuse metadata rewrite prefetchesReviewed the alias-resolution changes across A few points worth confirming before merge. 1.
|
|
Review posted to PR #2455. Summary of my findings: Review completeThe core change — resolving rewrite aliases so a prefetch cached under the rewrite destination is reused when navigating to the visible source URL — is correctly wired end-to-end across 4 points flagged (none blocking):
Plus one test nit ( |
726ba75 to
cb5c0c5
Compare
|
/bigbonk review for issues |
Review: reuse metadata rewrite prefetches (PR #2455)Re-reviewed the alias-resolution changes across I want to correct two claims in the earlier automated review that don't match the code as committed, then flag the points that do stand. Corrections to the prior review
Points that stand1. Duplicated rewrite-chain logic (maintenance hazard, not a bug).
Still, the two walkers must stay in lockstep; a future edit to one phase in only one function would silently desync the alias key from the owner decision. Extracting a shared "walk the rewrite chain" helper would remove the drift risk. Worth a follow-up, not blocking. 2. Double 3. 4. App Router prefetches now bypass VerdictNo blocking issues. The alias reuse is correctly implemented and well-tested. The earlier review's headline finding (#1) does not reproduce against the committed code. Remaining items are a maintenance-hazard follow-up (duplicated walker) and a minor hot-path optimization (double cache scan). |
|
Review posted to PR #2455. SummaryI re-reviewed the alias-reuse changes. The core mechanism — resolving rewrite aliases so a prefetch cached under the rewrite destination is reused for a navigation to the visible source URL — is correctly wired across Corrected two factual errors in the earlier automated review:
Points that stand (none blocking):
Verdict: no blocking issues; the PR's headline concern from the prior review does not reproduce against the committed code. |
NathanDrake2406
left a comment
There was a problem hiding this comment.
Requesting changes on structure.
The alias reuse direction looks right, but resolveHybridClientRewriteHref duplicates the rewrite traversal already owned by resolveHybridClientRouteOwner: beforeFiles, the dynamic-route gate, afterFiles, fallback, and document bailout now exist in two separate flows.
That makes the owner decision and the cache-alias href drift-prone. These are not separate concepts; they are two facts produced by the same route-resolution walk. Can we extract a single resolver that walks rewrites once and returns both the owner and the rewritten href, then have resolveHybridClientRouteOwner and the cache-alias path consume that shared result?
Something like:
type HybridClientRouteResolution =
| { kind: "document" }
| {
kind: "route";
owner: HybridClientOwner | null;
href: string;
rewritten: boolean;
};That would remove the duplicated state machine and make future rewrite-order changes much safer.
I also think prefetchUrl is carrying too much of this policy directly now: rewrite alias resolution, alias cache candidates, shell/full fetch orchestration, and the alias HEAD probe are all embedded in the same already-busy function. After the shared route-resolution helper exists, I’d prefer the cache-candidate construction to move behind a small helper as well, so link.tsx is not manually threading additionalRscUrls as an ad-hoc side channel.
|
I think this PR covers the segment-cache metadata failures from run 28478866791 / report job 84413308650. The report has exactly the two non-cacheComponents failures in |
…he-metadata-28478866791 # Conflicts: # packages/vinext/src/shims/link.tsx
…he-metadata-28478866791
…he-metadata-28478866791
…he-metadata-28478866791
…he-metadata-28478866791
|
Backlog mapping for GitHub Actions run 28478866791 / job 84413308650: this PR appears to own the App Router metadata rewrite/prefetch failures in Per instruction I am skipping a duplicate implementation because this PR is by |
This reverts commit bbff1eb.
…he-metadata-28478866791
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
…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
Validation
vp test run tests/prefetch-cache.test.ts tests/hybrid-client-route-owner.test.ts tests/link-navigation.test.tsvp check --fix packages/vinext/src/shims/link.tsx tests/e2e/app-router/nextjs-compat/segment-cache-metadata.browser.spec.tsvp run vinext#buildPLAYWRIGHT_PROJECT=app-router-chrome-browser-specific pnpm run test:e2e -- tests/e2e/app-router/nextjs-compat/segment-cache-metadata.browser.spec.tstest/e2e/app-dir/segment-cache/metadata/segment-cache-metadata.test.tspassedIndependent review loop completed with no findings.