next.js
adba1e3f - [PPF] Pass in original searchParams for private-cache pages (#98041)

Commit
14 days ago
[PPF] Pass in original searchParams for private-cache pages (#98041) The handing for page components marked with `use cache: private` was assuming that searchParams can never hang in `prerender-runtime`, so it passed the serialized `innerSearchParams` to the page, which we expected to just be a resolved promise. This *used to* be correct when runtime prerenders always had search params available, because the serialized search params were always equivalent to `outerSearchParams`. However, for `partialPrefetching` we started using `prerender-runtime` for runtime shells, where search params are not available, and if a private cache awaits them, it needs to abort filling and become dynamic, same as when it awaits params. So we need to trigger `dynamicAccessAbortController` when `searchParams` is awaited: ```tsx export default async function Page({ searchParams }) { 'use cache: private' // this should trigger `dynamicAccessAbortController.abort()`, so we need the original instrumented // searchParams object instead of the serialized one await searchParams } ``` This is fixed by using the outer searchParams object in the `isPageSegmentFunction` codepath of `use-cache-wrapper` -- we're preserving the instrumented promise, so the cache prerender will abort as expected. (before this fix, a shell prefetch of such a page would get a deserialized hanging promise for `searchParams` and hang until it times out) 2 of the 3 newly added tests ("params in a public cache" and "params in a private cache") were already passing, because `params` was already being preserved, but i'm adding them here to prevent regressions. The "search params in a private cache" one was failing due to the cache timing out, and is now passing. I'm not covering "search params in public cache" because that's an error and is already tested elsewhere.
Author
Parents
Loading