next.js
19a2bc1c - Propagate subtree prefetch hints to the route tree root

Commit
38 days ago
Propagate subtree prefetch hints to the route tree root The prefetch scheduler decides whether a `<Link prefetch={true}>` does a full prefetch (dynamic data included) or a partial, static-only one by reading a single hint at the root of the route tree: the bit that records whether any segment beneath it opted into Partial Prefetching. For that to be correct, an opt-in on a deeply nested segment — a page with `unstable_prefetch = 'partial'`, say — has to propagate all the way up to the root. Two places build a route tree and so must perform this propagation: the server, when it generates the prefetch route tree, and the client, when it merges a navigation patch into the existing tree. The client merge was copying each cloned segment's hints verbatim from the previous tree instead of recomputing them from the merged children, so the two could disagree. Pull the propagation into a shared helper used by both. A regression test covers a route whose opt-in lives several layout levels below the root and asserts that a `prefetch={true}` to it prefetches only the static shell, exercising propagation through the intermediate layouts.
Author
Committer
Parents
Loading