[PPF] Separate tracking of runtime data accesses for shells and prefetches (#98129)
Expands the static tracking from #96095 to track shells and prefetches separately. We split the `ShouldAttemptStaticPrefetch` hint into `ShouldAttemptStaticShell` and `ShouldAttemptStaticPrefetch`, which the client router considers separately depending on whether we need a shell or a prefetch. The server-side tracking of `needsRuntimeRequest` becomes a bit more subtle. First, a runtime data access should only affect the shell if we're in the `ShellStatic` render stage. If we're already in the `PrefetchStatic` stage, then that content is not conceptually part of the shell, and should not deopt the shell to runtime, so we only unset `shouldAttemptStaticShell` if we're still in the shell stage. Second, accessing data that would only resolve in the prefetch (params, search params, short-stale caches) should **not** affect whether the shell can be static. `makeRuntimeDataHangingPromise` has been split into variants that match this: - `makeSessionDataHangingPromise` - data that affects the shell (and the prefetch), e.g. `cookies()` - `makeURLDataHangingPromise` - data that only affects the prefetch, e.g. `params` - `makeUnknownRuntimeDataHangingPromise`, used for private caches -- we omit these during build so we don't know whether they should affect the shell or only the prefetch, so we conservatively affect both (unless a private cache is only used in the prefetch stage) The server-side `needsRuntimeRequest` promise is now resolved such that data that only resolves in the prefetch does not affect the shell. If we're accessing data that only resolves in the prefetch, we will delay the promise's resolution to the `PrefetchStatic` stage, which means that when the client rewinds the static response to a shell, it will see an unresolved promise and consider the response as not having used runtime data. (see `markRuntimeDataAccessWhenStageReached`)
Showing
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
test/lib/prefetch-hints.ts
0 → 100644
Please
register
or
sign in
to comment