Fix missing content in Cached Navigations (#98767)
React can render outlined elements in later `setImmediate` callbacks after an asynchronous cache read resolves. `cacheReady()` can resolve before those elements start their cached reads. The embedded prerender for Cached Navigations then reports unexpected cache misses and omits cacheable content. This change tracks pending native immediates in an `AsyncLocalStorage` scope around each Cache Components render. `CacheSignal` waits for that work before accepting a zero read count. If more native immediates appear before the readiness timer runs, it waits and checks again. Tracking does not make native immediates fast or change the existing explicit, task-local fast-immediate behavior. The e2e regression uses a delayed cache handler and a large outlined tree. It verifies that Cached Navigations reuse outlined content while content behind dynamic I/O remains uncached. Each test invocation uses a fresh cache key through `searchParams`, so cases and retries cannot reuse previously warmed entries. Unit tests in the existing immediates suite cover scope isolation, nested scheduling, cancellation, native scheduling semantics, and error recovery. Fixes #98543
Showing
This diff is collapsed.
This diff is collapsed.
Please
register
or
sign in
to comment