diff --git a/packages/next/src/client/components/router-reducer/apply-flight-data.ts b/packages/next/src/client/components/router-reducer/apply-flight-data.ts index 5003f47cbf5cf..7216636d5b0f2 100644 --- a/packages/next/src/client/components/router-reducer/apply-flight-data.ts +++ b/packages/next/src/client/components/router-reducer/apply-flight-data.ts @@ -7,7 +7,7 @@ export function applyFlightData( existingCache: CacheNode, cache: CacheNode, flightDataPath: FlightDataPath, - wasPrefetched: boolean = false + hasReusablePrefetch: boolean = false ): boolean { // The one before last item is the router state tree patch const [treePatch, cacheNodeSeedData, head] = flightDataPath.slice(-3) @@ -32,7 +32,7 @@ export function applyFlightData( treePatch, cacheNodeSeedData, head, - wasPrefetched + hasReusablePrefetch ) } else { // Copy rsc for the root node of the cache. @@ -47,7 +47,7 @@ export function applyFlightData( cache, existingCache, flightDataPath, - wasPrefetched + hasReusablePrefetch ) } diff --git a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts index 78768ad778d94..8d254203e74c5 100644 --- a/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts +++ b/packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts @@ -14,7 +14,7 @@ export function fillCacheWithNewSubTreeData( newCache: CacheNode, existingCache: CacheNode, flightDataPath: FlightDataPath, - wasPrefetched?: boolean + hasReusablePrefetch?: boolean ): void { const isLastEntry = flightDataPath.length <= 5 const [parallelRouteKey, segment] = flightDataPath @@ -71,7 +71,7 @@ export function fillCacheWithNewSubTreeData( flightDataPath[2], seedData, flightDataPath[4], - wasPrefetched + hasReusablePrefetch ) childSegmentMap.set(cacheKey, childCacheNode) @@ -99,6 +99,6 @@ export function fillCacheWithNewSubTreeData( childCacheNode, existingChildCacheNode, flightDataPath.slice(2), - wasPrefetched + hasReusablePrefetch ) } diff --git a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts index 1a596c4bb5cff..48b4c831a9fe1 100644 --- a/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts +++ b/packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts @@ -11,7 +11,7 @@ export function fillLazyItemsTillLeafWithHead( routerState: FlightRouterState, cacheNodeSeedData: CacheNodeSeedData | null, head: React.ReactNode, - wasPrefetched?: boolean + hasReusablePrefetch?: boolean ): void { const isLastSegment = Object.keys(routerState[1]).length === 0 if (isLastSegment) { @@ -59,9 +59,9 @@ export function fillLazyItemsTillLeafWithHead( prefetchRsc: null, parallelRoutes: new Map(existingCacheNode?.parallelRoutes), } - } else if (wasPrefetched && existingCacheNode) { + } else if (hasReusablePrefetch && existingCacheNode) { // No new data was sent from the server, but the existing cache node - // was prefetched, so we should reuse that. + // has a non-expired prefetch, so we should reuse that. newCacheNode = { lazyData: existingCacheNode.lazyData, rsc: existingCacheNode.rsc, @@ -72,7 +72,7 @@ export function fillLazyItemsTillLeafWithHead( parallelRoutes: new Map(existingCacheNode.parallelRoutes), } as CacheNode } else { - // No data available for this node. This will trigger a lazy fetch + // No data available for this node, or the prefetch entry expired. This will trigger a lazy fetch // during render. newCacheNode = { lazyData: null, @@ -91,7 +91,7 @@ export function fillLazyItemsTillLeafWithHead( parallelRouteState, parallelSeedData ? parallelSeedData : null, head, - wasPrefetched + hasReusablePrefetch ) newCache.parallelRoutes.set(key, parallelRouteCacheNode) @@ -133,7 +133,7 @@ export function fillLazyItemsTillLeafWithHead( parallelRouteState, parallelSeedData, head, - wasPrefetched + hasReusablePrefetch ) } } diff --git a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts index f135b730a2d3c..91b0785b29d38 100644 --- a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts @@ -166,7 +166,7 @@ function navigateReducer_noPPR( prefetchQueue.bump(data!) return data!.then( - ([flightData, canonicalUrlOverride, postponed]) => { + ([flightData, canonicalUrlOverride]) => { // we only want to mark this once if (prefetchValues && !prefetchValues.lastUsedTime) { // important: we should only mark the cache node as dirty after we unsuspend from the call above @@ -226,11 +226,8 @@ function navigateReducer_noPPR( ) if ( - (!applied && - prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale) || - // TODO-APP: If the prefetch was postponed, we don't want to apply it - // until we land router changes to handle the postponed case. - postponed + !applied && + prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale ) { applied = addRefetchToLeafSegments( cache,