Don't re-request the App Shell to upgrade an ISR fallback (#94808)
When a page hasn't been prerendered with concrete params yet, the server answers a per-segment prefetch with the fallback shell and flags it as upgradeable, and the client records that on the cache entries so a later prefetch of the same route can retry and pick up the concrete prerender once the server has generated it. The scheduler runs that retry from its Fulfilled-entry branch: any prefetch task that finds an upgradeable-fallback entry and hasn't retried yet spawns a revalidation for its own URL. That's right for the concrete static walk, where the retry can bring back the param-dependent content the fallback omitted. It's wrong for the Shell-phase walk under Partial Prefetching. A shell request asks for shell-stage content, and the fallback render already produced all of it: a concrete prerender's shell stage omits the same param-dependent content the fallback omitted, so the retry can only return the shell the cache already has. This shows up with root params. The shell varies only on the root params it reads, so a shell fetched for `/en/uk/posts/1` whose root layout reads `lang` but not `region` is keyed with `region` as a fallback, and a link to `/en/gb/posts/1` finds it in the cache. With the retry gate on, revealing that link re-requested the identical shell, once per link whose root params the shell doesn't read. The fix gates the ISR fallback retry on the walk's strategy, next to the Pending and Rejected branches that already skip revalidations during a static shell attempt. The per-task retry loop that the original fallback response starts is unchanged. The included test reveals three links from `/en/us`: `/en/uk/posts/1` fetches the shell, `/en/gb/posts/1` (same `lang`, different `region`) fetches nothing, and `/fr/uk/posts/1` (different `lang`) fetches a new shell. This PR originally narrowed the shell's cache key to the root params the server reported. That change landed separately in "Convert per-segment prefetches to NavigationFlightResponse format" (#96877); rebasing onto it left the test, which then caught this. <!-- NEXT_JS_LLM_PR -->
Showing
Please
register
or
sign in
to comment