Avoid timeout error when transformed params are passed to `"use cache"` (#80463)
With #79743, we're now providing a filled Resume Data Cache (RDC) when
prerendering optional fallback shells for routes that have some params
defined in `generateStaticParams`.
This allows us to treat a cache miss in the RDC as an indication that
params were part of the cache key. In this case, we can make the cache
function a dynamic hole in the shell (or produce an empty shell if
there's no parent suspense boundary).
Currently, this also includes layouts and pages that don't read params,
which will be improved when we implement NAR-136. Otherwise, we assume
that if params are passed explicitly into a `"use cache"` function, that
the params are also accessed (same as in #78882). This allows us to
abort early, and treat the function as dynamic, instead of waiting for
the timeout to be reached, even when params are transformed with an
async function, before being passed into the "use cache" function, e.g.:
```js
import { CachedComponent } from './cached-component'
async function getSlug(params) {
const { slug } = await params
return slug
}
export default function Page({ params }) {
return <CachedComponent slugPromise={getSlug(params)} />
}
export async function generateStaticParams() {
return [{ slug: 'foo' }]
}
```
This escapes the instrumentation we do to bailout early on fallback
params access. That handling is still needed though when prerendering
fallback shells of routes that don't have any params defined in
`generateStaticParams`, as we don't have a prefilled RDC in that case.