mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This fixes a bug where pages exporting `unstable_instant = false` cause their `'use cache'` reads to be incorrectly treated as dynamic, so the build emits an empty static shell where it should contain the cached content. The root cause sits in the cache wrapper's Resume Data Cache (RDC) miss bail-out. When prerendering a fallback shell whose RDC is the prefilled, read-only seed from a phase-1 prerender of a more-specific sibling route, a `'use cache'` miss is short-circuited to a dynamic hole — under that contract a miss means the cache key depends on a fallback param. That bail was gated on `workUnitStore.allowEmptyStaticShell`, which originally coincided with "we have a read-only seed" because the fallback-shell flow was the only thing setting the flag. #89077 widened the flag to also cover `unstable_instant = false`, which has no seed, so the bail started firing for routes that should be allowed to fill their caches normally. To fix this, we're replacing the proxy condition with the structural check `workUnitStore.resumeDataCache?.mutable === false`, which precisely matches the case the bail is for: a prerender whose RDC is the immutable, prefilled seed. This avoids the false positive for when `unstable_instant = false` is set and we're doing a prospective prerender with an empty mutable RDC. The check is type-narrowed via the discriminated union introduced in #94194, which is why that PR landed first. With the cache wrapper no longer the consumer, `workUnitStore.allowEmptyStaticShell` is removed from the prerender store — the flag survives only as `renderOpts.allowEmptyStaticShell` and a local parameter feeding the "shell may be empty for any reason" check in `dynamic-rendering.ts`.
5 lines
98 B
TypeScript
5 lines
98 B
TypeScript
export default async function Page() {
|
|
'use cache'
|
|
return <p>{new Date().toISOString()}</p>
|
|
}
|