Replicate production prefetch shells for instant navigations in dev
The Instant Navigation lock makes a development render reflect the route's prefetched state: while the lock is held, a navigation should show only what was prefetched and keep navigation-time data deferred. Both the `instant()` testing API from `@next/playwright` and the Instant Navigation devtools rely on it. The development render did not match what a production build serves in three ways: a route that blocks outside a `<Suspense>` boundary leaked its data instead of staying parked, the shell did not defer params the way a production prefetch would, and the data a runtime prefetch resolves did not surface inside the scope. While the lock is held, the app render now permits an empty static shell. A route that reads dynamic data such as `cookies()` outside any `<Suspense>` boundary has no static shell, so the on-demand render previously threw a static generation bailout, served an error page, and entered a `/_tree` redirect loop that committed the blocked data. Permitting an empty shell lets the render emit the shell instead. The override is scoped to the prefetch render made while the lock is held, a document request or a `'1'` static prefetch; a regular dynamic navigation, including the one that commits once the lock releases, runs without it. So the validation that flags a blocking route is not weakened: production validation runs at build time, and the development validation still runs and is shown in the dev overlay. The development fallback-shell render now reads the per-URL `fallbackParams` request meta that the server derives for the requested URL, so the instant shell defers exactly the params a production prefetch would: `generateStaticParams`-covered params resolve in the shell and only the uncovered ones are deferred. When the URL is fully covered the meta is absent and nothing is deferred. That per-URL computation is introduced by the preceding change in this stack, and this change depends on it: with the earlier fewest-param heuristic, three of the instant-navigation tests fail. Under the Instant Navigation lock the captured shell should reflect the fully settled prefetched state, what the route would look like once every in-flight prefetch has landed. The segment cache normally prefers a ready entry over a more-specific in-flight one so a real navigation is not stalled, but under the lock that ready entry can be a less-specific, stale shell while a more-specific prefetch is still resolving. So under the lock it now prefers the more-specific in-flight entry, which is what produces the complete settled picture: the data a runtime prefetch resolves (dynamic params among other runtime-stage reads) surfaces inside the scope, and a blocked navigation into a deeper fallback segment stays parked on the committed shell instead of committing a stale resolved entry. This matches the best case in production, where the runtime prefetch has written its entry before the navigation reads it. Enabling App Shells in the default fixture makes the app shell carry a cookie that is read with no preceding param access, so the existing client-navigation cookie test is updated to assert the cookie is present in the instant shell, alongside a new param-gated variation that asserts it is excluded when a param is read first. New cases cover mixed static and fallback params under both a normal navigation and a runtime prefetch, and a deeper-segment blocking navigation that must stay parked on the committed parent. A blocking route that reads request data outside any `<Suspense>` boundary cannot be built for production, so it is isolated in a development-only fixture and guarded so the production job registers only a placeholder.
Showing
Please
register
or
sign in
to comment