Commit 567d6050 authored by Zack Tanner's avatar Zack Tanner

add handling to skip prefetch payloads if partial

parent bc1adb24
......@@ -1073,6 +1073,14 @@ function createCacheNodeForSegment(
doesSegmentNeedDynamicRequest = isCachedRscPartial
}
if (isCachedRscPartial) {
// Partial prefetch payloads may include unresolved thenables that never
// resolve during prefetch. We must not render them as initial UI, or a
// Suspense boundary can remain stuck in its fallback indefinitely. Only
// the dynamic response should fulfill missing data.
prefetchRsc = null
}
// If this is a page segment, we need to do the same for the head. This
// follows analogous logic to the segment data above.
// TODO: We don't need to store the head on the page segment's CacheNode; we
......@@ -1082,10 +1090,10 @@ function createCacheNodeForSegment(
let prefetchHead: HeadData | null = null
let head: React.ReactNode | null = null
let doesHeadNeedDynamicRequest: boolean = isPage
let isCachedHeadPartial: boolean = true
if (isPage) {
let cachedHead: HeadData | null = null
let isCachedHeadPartial: boolean = true
if (metadataVaryPath !== null) {
const metadataEntry = readSegmentCacheEntry(now, metadataVaryPath)
if (metadataEntry !== null) {
......@@ -1154,6 +1162,12 @@ function createCacheNodeForSegment(
}
}
if (isPage && isCachedHeadPartial) {
// Same rationale as prefetchRsc: avoid rendering partial head data that may
// contain unresolved thenables.
prefetchHead = null
}
// Now that we're creating a new segment, write its data to the BFCache. A
// subsequent back/forward navigation will reuse this same data, until or
// unless it's cleared by a refresh/revalidation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment