Skip to content

Commit 72ce8b5

Browse files
committed
[Segment Cache] Re-implement refresh reducer
This re-implements the refresh reducer to use the Segment Cache-style flow, similar to how the navigate reducer already works. Most of the logic can be reused from what was already implemented for navigations. The bulk of the changes are related to the case where a "default" parallel route slot is not present on the current page, and so needs to be refreshed from an older page's URL. Theoretically, this should be the last remaining case where we rely on the lazy fetching logic in LayoutRouter. I think there may still be some error cases where we still rely on that, though. Once these are all addressed, we can remove the lazy-fetching mechanism entirely.
1 parent dcb6235 commit 72ce8b5

File tree

21 files changed

+780
-153
lines changed

21 files changed

+780
-153
lines changed

packages/next/src/client/components/layout-router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ function InnerLayoutRouter({
374374
// The data for this segment is not available, and there's no pending
375375
// navigation that will be able to fulfill it. We need to fetch more from
376376
// the server and patch the cache.
377+
// TODO: Remove this lazy fetch when Segment Cache is enabled once the
378+
// remaining parts of the router are re-implemented to no longer rely on it.
377379

378380
// Check if there's already a pending request.
379381
let lazyData = cacheNode.lazyData

packages/next/src/client/components/router-reducer/create-initial-router-state.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export function createInitialRouterState({
7171
createHrefFromUrl(location)
7272
: initialCanonicalUrl
7373

74-
addRefreshMarkerToActiveParallelSegments(initialTree, canonicalUrl)
74+
if (!process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
75+
addRefreshMarkerToActiveParallelSegments(initialTree, canonicalUrl)
76+
}
7577

7678
const prefetchCache = new Map<string, PrefetchCacheEntry>()
7779

0 commit comments

Comments
 (0)