Unverified Commit df247d1b authored by Andrew Clark's avatar Andrew Clark Committed by GitHub

Move prefetch hints from CacheNodeSeedData to FlightRouterState (#90066)

## Summary

Prefetch hints were previously stored in CacheNodeSeedData — the payload
the server sends for each segment's React content. This moves them to
FlightRouterState, the route tree structure that the server sends
alongside the seed data. FlightRouterState is a better home because
prefetch hints describe properties of the route structure (loading
boundaries, instant configs) rather than properties of the rendered
content. It also ensures that hints are always available during
navigations, not just prefetches.

Since this changes the FlightRouterState tuple layout anyway, it also
folds the existing `isRootLayout` boolean and `HasLoadingBoundary` enum
into the same bitmask field at FlightRouterState[4].

## Test plan

- Existing unit tests updated for new format
(`flight-data-helpers.test.ts`, `types.test.ts`)
- MPA navigation test validates root layout change detection via bitmask
- `prefetch-true-instant` e2e test validates Link `prefetch={true}`
behavior with instant routes
parent 55ea60e6
import { computeChangedPath } from './compute-changed-path' import { computeChangedPath } from './compute-changed-path'
import { PrefetchHint } from '../../../shared/lib/app-router-types'
describe('computeChangedPath', () => { describe('computeChangedPath', () => {
it('should return the correct path', () => { it('should return the correct path', () => {
...@@ -27,7 +28,7 @@ describe('computeChangedPath', () => { ...@@ -27,7 +28,7 @@ describe('computeChangedPath', () => {
}, },
undefined, undefined,
undefined, undefined,
true, PrefetchHint.IsRootLayout,
], ],
[ [
'', '',
...@@ -52,7 +53,7 @@ describe('computeChangedPath', () => { ...@@ -52,7 +53,7 @@ describe('computeChangedPath', () => {
}, },
undefined, undefined,
undefined, undefined,
true, PrefetchHint.IsRootLayout,
] ]
) )
).toBe('/') ).toBe('/')
......
import type { FlightRouterState } from '../../../shared/lib/app-router-types' import type { FlightRouterState } from '../../../shared/lib/app-router-types'
import { PrefetchHint } from '../../../shared/lib/app-router-types'
import type { RouteTree } from '../segment-cache/cache' import type { RouteTree } from '../segment-cache/cache'
export function isNavigatingToNewRootLayout( export function isNavigatingToNewRootLayout(
...@@ -26,12 +27,16 @@ export function isNavigatingToNewRootLayout( ...@@ -26,12 +27,16 @@ export function isNavigatingToNewRootLayout(
} }
// Current tree root layout found // Current tree root layout found
if (currentTree[4]) { const currentIsRootLayout =
((currentTree[4] ?? 0) & PrefetchHint.IsRootLayout) !== 0
const nextIsRootLayout =
(nextTree.prefetchHints & PrefetchHint.IsRootLayout) !== 0
if (currentIsRootLayout) {
// If the next tree doesn't have the root layout flag, it must have changed. // If the next tree doesn't have the root layout flag, it must have changed.
return !nextTree.isRootLayout return !nextIsRootLayout
} }
// Current tree didn't have its root layout here, must have changed. // Current tree didn't have its root layout here, must have changed.
if (nextTree.isRootLayout) { if (nextIsRootLayout) {
return true return true
} }
......
...@@ -6,6 +6,7 @@ import type { ...@@ -6,6 +6,7 @@ import type {
} from '../../../shared/lib/app-router-types' } from '../../../shared/lib/app-router-types'
import type { CacheNode } from '../../../shared/lib/app-router-types' import type { CacheNode } from '../../../shared/lib/app-router-types'
import type { HeadData } from '../../../shared/lib/app-router-types' import type { HeadData } from '../../../shared/lib/app-router-types'
import { PrefetchHint } from '../../../shared/lib/app-router-types'
import { import {
PAGE_SEGMENT_KEY, PAGE_SEGMENT_KEY,
DEFAULT_SEGMENT_KEY, DEFAULT_SEGMENT_KEY,
...@@ -315,7 +316,9 @@ function updateCacheNodeOnNavigation( ...@@ -315,7 +316,9 @@ function updateCacheNodeOnNavigation(
// We're currently traversing the part of the tree that was also part of // We're currently traversing the part of the tree that was also part of
// the previous route. If we discover a root layout, then we don't need to // the previous route. If we discover a root layout, then we don't need to
// trigger an MPA navigation. // trigger an MPA navigation.
const childDidFindRootLayout = didFindRootLayout || newRouteTree.isRootLayout const childDidFindRootLayout =
didFindRootLayout ||
(newRouteTree.prefetchHints & PrefetchHint.IsRootLayout) !== 0
let shouldRefreshDynamicData: boolean = false let shouldRefreshDynamicData: boolean = false
switch (freshness) { switch (freshness) {
...@@ -534,7 +537,7 @@ function updateCacheNodeOnNavigation( ...@@ -534,7 +537,7 @@ function updateCacheNodeOnNavigation(
? [refreshState.canonicalUrl, refreshState.renderedSearch] ? [refreshState.canonicalUrl, refreshState.renderedSearch]
: null, : null,
null, null,
newRouteTree.isRootLayout, newRouteTree.prefetchHints,
] ]
return { return {
...@@ -670,7 +673,7 @@ function createCacheNodeOnNavigation( ...@@ -670,7 +673,7 @@ function createCacheNodeOnNavigation(
patchedRouterStateChildren, patchedRouterStateChildren,
null, null,
null, null,
newRouteTree.isRootLayout, newRouteTree.prefetchHints,
] ]
return { return {
......
import React from 'react' import React from 'react'
import type { import {
FlightData, PrefetchHint,
FlightRouterState, type FlightData,
type FlightRouterState,
} from '../../../shared/lib/app-router-types' } from '../../../shared/lib/app-router-types'
import { shouldHardNavigate } from './should-hard-navigate' import { shouldHardNavigate } from './should-hard-navigate'
...@@ -19,7 +20,7 @@ describe('shouldHardNavigate', () => { ...@@ -19,7 +20,7 @@ describe('shouldHardNavigate', () => {
}, },
undefined, undefined,
undefined, undefined,
true, PrefetchHint.IsRootLayout,
] ]
const initialRouterStateTree = getInitialRouterStateTree() const initialRouterStateTree = getInitialRouterStateTree()
const getFlightData = (): FlightData => { const getFlightData = (): FlightData => {
...@@ -78,7 +79,7 @@ describe('shouldHardNavigate', () => { ...@@ -78,7 +79,7 @@ describe('shouldHardNavigate', () => {
}, },
null, null,
null, null,
true, PrefetchHint.IsRootLayout,
] ]
const initialRouterStateTree = getInitialRouterStateTree() const initialRouterStateTree = getInitialRouterStateTree()
const getFlightData = (): FlightData => { const getFlightData = (): FlightData => {
...@@ -135,7 +136,7 @@ describe('shouldHardNavigate', () => { ...@@ -135,7 +136,7 @@ describe('shouldHardNavigate', () => {
}, },
null, null,
null, null,
true, PrefetchHint.IsRootLayout,
] ]
const initialRouterStateTree = getInitialRouterStateTree() const initialRouterStateTree = getInitialRouterStateTree()
const getFlightData = (): FlightData => { const getFlightData = (): FlightData => {
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
readVaryParams, readVaryParams,
type VaryParams, type VaryParams,
} from '../../../shared/lib/segment-cache/vary-params-decoding' } from '../../../shared/lib/segment-cache/vary-params-decoding'
import { HasLoadingBoundary } from '../../../shared/lib/app-router-types'
import { import {
NEXT_DID_POSTPONE_HEADER, NEXT_DID_POSTPONE_HEADER,
NEXT_INSTANT_PREFETCH_HEADER, NEXT_INSTANT_PREFETCH_HEADER,
...@@ -145,20 +144,9 @@ type RouteTreeShared = { ...@@ -145,20 +144,9 @@ type RouteTreeShared = {
slots: null | { slots: null | {
[parallelRouteKey: string]: RouteTree [parallelRouteKey: string]: RouteTree
} }
isRootLayout: boolean // Bitmask of PrefetchHint flags. Encodes route structure metadata:
// root layout, loading boundaries, instant configs, and runtime prefetch
// If this is a dynamic route, indicates whether there is a loading boundary // hints.
// somewhere in the tree. If not, we can skip the prefetch for the data,
// because we know it would be an empty response. (For a static/PPR route,
// this value is disregarded, because in that model `loading.tsx` is treated
// like any other Suspense boundary.)
hasLoadingBoundary: HasLoadingBoundary
// Bitmask of PrefetchHint flags. Indicates whether this segment has a
// runtime prefetch, and whether the subtree contains any instant configs.
// Determined by the server; not purely a user configuration because the
// server may determine that a route is fully static and doesn't need
// runtime prefetching regardless of the configuration.
prefetchHints: number prefetchHints: number
} }
...@@ -721,8 +709,7 @@ function deprecated_createOptimisticRouteTree( ...@@ -721,8 +709,7 @@ function deprecated_createOptimisticRouteTree(
), ),
isPage: true, isPage: true,
slots: clonedSlots, slots: clonedSlots,
isRootLayout: tree.isRootLayout,
hasLoadingBoundary: tree.hasLoadingBoundary,
prefetchHints: tree.prefetchHints, prefetchHints: tree.prefetchHints,
} }
} }
...@@ -734,8 +721,6 @@ function deprecated_createOptimisticRouteTree( ...@@ -734,8 +721,6 @@ function deprecated_createOptimisticRouteTree(
varyPath: tree.varyPath, varyPath: tree.varyPath,
isPage: false, isPage: false,
slots: clonedSlots, slots: clonedSlots,
isRootLayout: tree.isRootLayout,
hasLoadingBoundary: tree.hasLoadingBoundary,
prefetchHints: tree.prefetchHints, prefetchHints: tree.prefetchHints,
} }
} }
...@@ -1017,8 +1002,6 @@ export function createMetadataRouteTree( ...@@ -1017,8 +1002,6 @@ export function createMetadataRouteTree(
// one. If this logic ever gets more complex we can change this to an enum. // one. If this logic ever gets more complex we can change this to an enum.
isPage: true, isPage: true,
slots: null, slots: null,
isRootLayout: false,
hasLoadingBoundary: HasLoadingBoundary.SubtreeHasNoLoadingBoundary,
prefetchHints: 0, prefetchHints: 0,
} }
return metadata return metadata
...@@ -1318,10 +1301,6 @@ function convertTreePrefetchToRouteTree( ...@@ -1318,10 +1301,6 @@ function convertTreePrefetchToRouteTree(
varyPath: varyPath as any, varyPath: varyPath as any,
isPage: isPage as boolean as any, isPage: isPage as boolean as any,
slots, slots,
isRootLayout: prefetch.isRootLayout,
// This field is only relevant to dynamic routes. For a PPR/static route,
// there's always some partial loading state we can fetch.
hasLoadingBoundary: HasLoadingBoundary.SegmentHasLoadingBoundary,
prefetchHints: prefetch.prefetchHints, prefetchHints: prefetch.prefetchHints,
} }
} }
...@@ -1501,15 +1480,7 @@ function convertFlightRouterStateToRouteTree( ...@@ -1501,15 +1480,7 @@ function convertFlightRouterStateToRouteTree(
varyPath: varyPath as any, varyPath: varyPath as any,
isPage: isPage as boolean as any, isPage: isPage as boolean as any,
slots, slots,
isRootLayout: flightRouterState[4] === true, prefetchHints: flightRouterState[4] ?? 0,
hasLoadingBoundary:
flightRouterState[5] !== undefined
? flightRouterState[5]
: HasLoadingBoundary.SubtreeHasNoLoadingBoundary,
// Non-static tree responses are only used by apps that haven't adopted
// Cache Components. So this is always 0.
prefetchHints: 0,
} }
} }
...@@ -1529,7 +1500,6 @@ export function convertRouteTreeToFlightRouterState( ...@@ -1529,7 +1500,6 @@ export function convertRouteTreeToFlightRouterState(
parallelRoutes, parallelRoutes,
null, null,
null, null,
routeTree.isRootLayout,
] ]
return flightRouterState return flightRouterState
} }
...@@ -2349,7 +2319,7 @@ function writeSeedDataIntoCache( ...@@ -2349,7 +2319,7 @@ function writeSeedDataIntoCache(
// (CacheNodeSeedData) into the prefetch cache. // (CacheNodeSeedData) into the prefetch cache.
const rsc = seedData[0] const rsc = seedData[0]
const isPartial = rsc === null || isResponsePartial const isPartial = rsc === null || isResponsePartial
const varyParamsThenable = seedData[5] const varyParamsThenable = seedData[4]
// Each segment carries its own vary params thenable in the seed data. The // Each segment carries its own vary params thenable in the seed data. The
// thenable resolves to the set of params the segment accessed during render. // thenable resolves to the set of params the segment accessed during render.
// A null thenable means tracking was not enabled (not a prerender). // A null thenable means tracking was not enabled (not a prerender).
......
...@@ -764,7 +764,6 @@ function convertServerPatchToFullTreeImpl( ...@@ -764,7 +764,6 @@ function convertServerPatchToFullTreeImpl(
newSeedDataChildren, newSeedDataChildren,
null, null,
isEmptySeedDataPartial, isEmptySeedDataPartial,
0,
null, null,
] ]
......
...@@ -797,8 +797,7 @@ function reifyRouteTree( ...@@ -797,8 +797,7 @@ function reifyRouteTree(
segment: newSegment, segment: newSegment,
refreshState: pattern.refreshState, refreshState: pattern.refreshState,
slots: newSlots, slots: newSlots,
isRootLayout: pattern.isRootLayout,
hasLoadingBoundary: pattern.hasLoadingBoundary,
prefetchHints: pattern.prefetchHints, prefetchHints: pattern.prefetchHints,
isPage: true, isPage: true,
varyPath: newVaryPath, varyPath: newVaryPath,
...@@ -814,8 +813,7 @@ function reifyRouteTree( ...@@ -814,8 +813,7 @@ function reifyRouteTree(
segment: newSegment, segment: newSegment,
refreshState: pattern.refreshState, refreshState: pattern.refreshState,
slots: newSlots, slots: newSlots,
isRootLayout: pattern.isRootLayout,
hasLoadingBoundary: pattern.hasLoadingBoundary,
prefetchHints: pattern.prefetchHints, prefetchHints: pattern.prefetchHints,
isPage: false, isPage: false,
varyPath: newVaryPath, varyPath: newVaryPath,
......
...@@ -3,10 +3,7 @@ import type { ...@@ -3,10 +3,7 @@ import type {
Segment as FlightRouterStateSegment, Segment as FlightRouterStateSegment,
Segment, Segment,
} from '../../../shared/lib/app-router-types' } from '../../../shared/lib/app-router-types'
import { import { PrefetchHint } from '../../../shared/lib/app-router-types'
HasLoadingBoundary,
PrefetchHint,
} from '../../../shared/lib/app-router-types'
import { matchSegment } from '../match-segments' import { matchSegment } from '../match-segments'
import { import {
readOrCreateRouteCacheEntry, readOrCreateRouteCacheEntry,
...@@ -1107,8 +1104,10 @@ function diffRouteTreeAgainstCurrent( ...@@ -1107,8 +1104,10 @@ function diffRouteTreeAgainstCurrent(
// anywhere in the tree, the server will never return any data, so // anywhere in the tree, the server will never return any data, so
// we can skip the request. // we can skip the request.
const subtreeHasLoadingBoundary = const subtreeHasLoadingBoundary =
newTreeChild.hasLoadingBoundary !== (newTreeChild.prefetchHints &
HasLoadingBoundary.SubtreeHasNoLoadingBoundary (PrefetchHint.SegmentHasLoadingBoundary |
PrefetchHint.SubtreeHasLoadingBoundary)) !==
0
const requestTreeChild = subtreeHasLoadingBoundary const requestTreeChild = subtreeHasLoadingBoundary
? pingPPRDisabledRouteTreeUpToLoadingBoundary( ? pingPPRDisabledRouteTreeUpToLoadingBoundary(
now, now,
...@@ -1179,7 +1178,6 @@ function diffRouteTreeAgainstCurrent( ...@@ -1179,7 +1178,6 @@ function diffRouteTreeAgainstCurrent(
requestTreeChildren, requestTreeChildren,
null, null,
null, null,
newTree.isRootLayout,
] ]
return requestTree return requestTree
} }
...@@ -1239,7 +1237,7 @@ function pingPPRDisabledRouteTreeUpToLoadingBoundary( ...@@ -1239,7 +1237,7 @@ function pingPPRDisabledRouteTreeUpToLoadingBoundary(
case EntryStatus.Fulfilled: { case EntryStatus.Fulfilled: {
// The segment is already cached. // The segment is already cached.
const segmentHasLoadingBoundary = const segmentHasLoadingBoundary =
tree.hasLoadingBoundary === HasLoadingBoundary.SegmentHasLoadingBoundary (tree.prefetchHints & PrefetchHint.SegmentHasLoadingBoundary) !== 0
if (segmentHasLoadingBoundary) { if (segmentHasLoadingBoundary) {
// This segment has a loading boundary, which means the server won't // This segment has a loading boundary, which means the server won't
// render its children. So there's nothing left to prefetch along this // render its children. So there's nothing left to prefetch along this
...@@ -1287,7 +1285,6 @@ function pingPPRDisabledRouteTreeUpToLoadingBoundary( ...@@ -1287,7 +1285,6 @@ function pingPPRDisabledRouteTreeUpToLoadingBoundary(
requestTreeChildren, requestTreeChildren,
null, null,
refetchMarker, refetchMarker,
tree.isRootLayout,
] ]
return requestTree return requestTree
} }
...@@ -1407,7 +1404,6 @@ function pingRouteTreeAndIncludeDynamicData( ...@@ -1407,7 +1404,6 @@ function pingRouteTreeAndIncludeDynamicData(
requestTreeChildren, requestTreeChildren,
null, null,
refetchMarker, refetchMarker,
tree.isRootLayout,
] ]
return requestTree return requestTree
} }
......
import { prepareFlightRouterStateForRequest } from './flight-data-helpers' import { prepareFlightRouterStateForRequest } from './flight-data-helpers'
import { import {
HasLoadingBoundary, PrefetchHint,
type FlightRouterState, type FlightRouterState,
} from '../shared/lib/app-router-types' } from '../shared/lib/app-router-types'
...@@ -12,8 +12,7 @@ describe('prepareFlightRouterStateForRequest', () => { ...@@ -12,8 +12,7 @@ describe('prepareFlightRouterStateForRequest', () => {
{}, {},
['/some/url', ''], ['/some/url', ''],
'refetch', 'refetch',
true, PrefetchHint.IsRootLayout | 1,
1,
] ]
const result = prepareFlightRouterStateForRequest(flightRouterState, true) const result = prepareFlightRouterStateForRequest(flightRouterState, true)
...@@ -130,50 +129,34 @@ describe('prepareFlightRouterStateForRequest', () => { ...@@ -130,50 +129,34 @@ describe('prepareFlightRouterStateForRequest', () => {
}) })
describe('optional fields preservation', () => { describe('optional fields preservation', () => {
it('should preserve isRootLayout when true', () => { it('should preserve prefetchHints with IsRootLayout', () => {
const flightRouterState: FlightRouterState = [ const flightRouterState: FlightRouterState = [
'segment', 'segment',
{}, {},
null, null,
null, null,
true, PrefetchHint.IsRootLayout,
] ]
const result = prepareFlightRouterStateForRequest(flightRouterState) const result = prepareFlightRouterStateForRequest(flightRouterState)
const decoded = JSON.parse(decodeURIComponent(result)) const decoded = JSON.parse(decodeURIComponent(result))
expect(decoded[4]).toBe(true) expect(decoded[4]).toBe(PrefetchHint.IsRootLayout)
}) })
it('should preserve isRootLayout when false', () => { it('should preserve prefetchHints with SegmentHasLoadingBoundary', () => {
const flightRouterState: FlightRouterState = [ const flightRouterState: FlightRouterState = [
'segment', 'segment',
{}, {},
null, null,
null, null,
false, PrefetchHint.SegmentHasLoadingBoundary,
] ]
const result = prepareFlightRouterStateForRequest(flightRouterState) const result = prepareFlightRouterStateForRequest(flightRouterState)
const decoded = JSON.parse(decodeURIComponent(result)) const decoded = JSON.parse(decodeURIComponent(result))
expect(decoded[4]).toBe(false) expect(decoded[4]).toBe(PrefetchHint.SegmentHasLoadingBoundary)
})
it('should preserve hasLoadingBoundary', () => {
const flightRouterState: FlightRouterState = [
'segment',
{},
null,
null,
undefined,
1, // HasLoadingBoundary value
]
const result = prepareFlightRouterStateForRequest(flightRouterState)
const decoded = JSON.parse(decodeURIComponent(result))
expect(decoded[5]).toBe(1)
}) })
it('should handle minimal FlightRouterState (only segment and parallelRoutes)', () => { it('should handle minimal FlightRouterState (only segment and parallelRoutes)', () => {
...@@ -262,14 +245,12 @@ describe('prepareFlightRouterStateForRequest', () => { ...@@ -262,14 +245,12 @@ describe('prepareFlightRouterStateForRequest', () => {
{}, {},
['/modal/path', ''], ['/modal/path', ''],
null, null,
false, PrefetchHint.SegmentHasLoadingBoundary,
HasLoadingBoundary.SegmentHasLoadingBoundary,
], ],
}, },
['/dashboard/url', ''], ['/dashboard/url', ''],
'refetch', 'refetch',
true, PrefetchHint.IsRootLayout | PrefetchHint.SegmentHasLoadingBoundary,
1,
], ],
sidebar: [ sidebar: [
['slug', 'user-123', 'd', null], ['slug', 'user-123', 'd', null],
...@@ -280,8 +261,7 @@ describe('prepareFlightRouterStateForRequest', () => { ...@@ -280,8 +261,7 @@ describe('prepareFlightRouterStateForRequest', () => {
}, },
['/main/url', ''], ['/main/url', ''],
'inside-shared-layout', 'inside-shared-layout',
true, PrefetchHint.IsRootLayout | PrefetchHint.SegmentHasLoadingBoundary,
1,
] ]
const result = prepareFlightRouterStateForRequest(complexState) const result = prepareFlightRouterStateForRequest(complexState)
...@@ -291,22 +271,24 @@ describe('prepareFlightRouterStateForRequest', () => { ...@@ -291,22 +271,24 @@ describe('prepareFlightRouterStateForRequest', () => {
expect(decoded[0]).toBe('__PAGE__') // search params stripped expect(decoded[0]).toBe('__PAGE__') // search params stripped
expect(decoded[2]).toBeNull() // URL stripped expect(decoded[2]).toBeNull() // URL stripped
expect(decoded[3]).toBe('inside-shared-layout') // server marker preserved expect(decoded[3]).toBe('inside-shared-layout') // server marker preserved
expect(decoded[4]).toBe(true) // isRootLayout preserved expect(decoded[4]).toBe(
expect(decoded[5]).toBe(1) // hasLoadingBoundary preserved PrefetchHint.IsRootLayout | PrefetchHint.SegmentHasLoadingBoundary
) // prefetchHints preserved
// Children route checks // Children route checks
const childrenRoute = decoded[1].children const childrenRoute = decoded[1].children
expect(childrenRoute[2]).toBeNull() // URL stripped expect(childrenRoute[2]).toBeNull() // URL stripped
expect(childrenRoute[3]).toBe('refetch') // server marker preserved expect(childrenRoute[3]).toBe('refetch') // server marker preserved
expect(childrenRoute[4]).toBe(true) // isRootLayout preserved expect(childrenRoute[4]).toBe(
PrefetchHint.IsRootLayout | PrefetchHint.SegmentHasLoadingBoundary
) // prefetchHints preserved
// Modal route checks // Modal route checks
const modalRoute = childrenRoute[1].modal const modalRoute = childrenRoute[1].modal
expect(modalRoute[0]).toBe('__PAGE__') // search params stripped expect(modalRoute[0]).toBe('__PAGE__') // search params stripped
expect(modalRoute[2]).toBeNull() // URL stripped expect(modalRoute[2]).toBeNull() // URL stripped
expect(modalRoute[3]).toBeNull() // 'refresh' marker stripped expect(modalRoute[3]).toBeNull() // 'refresh' marker stripped
expect(modalRoute[4]).toBe(false) // isRootLayout preserved expect(modalRoute[4]).toBe(PrefetchHint.SegmentHasLoadingBoundary) // prefetchHints preserved
expect(modalRoute[5]).toBe(HasLoadingBoundary.SegmentHasLoadingBoundary) // hasLoadingBoundary preserved
// Sidebar route (dynamic segment) checks // Sidebar route (dynamic segment) checks
const sidebarRoute = decoded[1].sidebar const sidebarRoute = decoded[1].sidebar
......
...@@ -251,8 +251,7 @@ function stripClientOnlyDataFromFlightRouterState( ...@@ -251,8 +251,7 @@ function stripClientOnlyDataFromFlightRouterState(
parallelRoutes, parallelRoutes,
_refreshState, // Intentionally unused - URLs are client-only _refreshState, // Intentionally unused - URLs are client-only
refreshMarker, refreshMarker,
isRootLayout, prefetchHints,
hasLoadingBoundary,
] = flightRouterState ] = flightRouterState
// Strip client-only data from the segment // Strip client-only data from the segment
...@@ -272,11 +271,8 @@ function stripClientOnlyDataFromFlightRouterState( ...@@ -272,11 +271,8 @@ function stripClientOnlyDataFromFlightRouterState(
} }
// Append optional fields if present // Append optional fields if present
if (isRootLayout !== undefined) { if (prefetchHints !== undefined) {
result[4] = isRootLayout result[4] = prefetchHints
}
if (hasLoadingBoundary !== undefined) {
result[5] = hasLoadingBoundary
} }
// Everything else is used only by the client and is not needed for requests. // Everything else is used only by the client and is not needed for requests.
......
...@@ -1525,7 +1525,7 @@ async function getRSCPayload( ...@@ -1525,7 +1525,7 @@ async function getRSCPayload(
workStore, workStore,
} = ctx } = ctx
const initialTree = createFlightRouterStateFromLoaderTree( const initialTree = await createFlightRouterStateFromLoaderTree(
tree, tree,
getDynamicParamFromSegment, getDynamicParamFromSegment,
query query
...@@ -1689,7 +1689,7 @@ async function getErrorRSCPayload( ...@@ -1689,7 +1689,7 @@ async function getErrorRSCPayload(
createElement(Metadata, null) createElement(Metadata, null)
) )
const initialTree = createFlightRouterStateFromLoaderTree( const initialTree = await createFlightRouterStateFromLoaderTree(
tree, tree,
getDynamicParamFromSegment, getDynamicParamFromSegment,
query query
...@@ -1724,7 +1724,6 @@ async function getErrorRSCPayload( ...@@ -1724,7 +1724,6 @@ async function getErrorRSCPayload(
{}, {},
null, null,
false, false,
0, // We don't currently support runtime prefetching for error pages.
null, // varyParams - not tracked for error pages null, // varyParams - not tracked for error pages
] ]
......
...@@ -68,13 +68,6 @@ export type TreePrefetch = { ...@@ -68,13 +68,6 @@ export type TreePrefetch = {
/** Bitmask of PrefetchHint flags for this segment and its subtree */ /** Bitmask of PrefetchHint flags for this segment and its subtree */
prefetchHints: number prefetchHints: number
// Extra fields that only exist so we can reconstruct a FlightRouterState on
// the client. We may be able to unify TreePrefetch and FlightRouterState
// after some refactoring, but in the meantime it would be wasteful to add a
// bunch of new prefetch-only fields to FlightRouterState. So think of
// TreePrefetch as a superset of FlightRouterState.
isRootLayout: boolean
} }
export type SegmentPrefetch = { export type SegmentPrefetch = {
...@@ -345,14 +338,14 @@ function collectSegmentDataImpl( ...@@ -345,14 +338,14 @@ function collectSegmentDataImpl(
slotMetadata[parallelRouteKey] = childTree slotMetadata[parallelRouteKey] = childTree
} }
const prefetchHints = seedData !== null ? seedData[4] : 0 const prefetchHints = route[4] ?? 0
// Determine which params this segment varies on. // Determine which params this segment varies on.
// Read the vary params thenable directly from the seed data. By the time // Read the vary params thenable directly from the seed data. By the time
// collectSegmentData runs, the thenable should be fulfilled. If it's not // collectSegmentData runs, the thenable should be fulfilled. If it's not
// fulfilled or null, treat as unknown (null means we can't share cache // fulfilled or null, treat as unknown (null means we can't share cache
// entries across param values). // entries across param values).
const varyParamsThenable = seedData !== null ? seedData[5] : null const varyParamsThenable = seedData !== null ? seedData[4] : null
const varyParams = const varyParams =
varyParamsThenable !== null ? readVaryParams(varyParamsThenable) : null varyParamsThenable !== null ? readVaryParams(varyParamsThenable) : null
...@@ -404,7 +397,6 @@ function collectSegmentDataImpl( ...@@ -404,7 +397,6 @@ function collectSegmentDataImpl(
param, param,
prefetchHints, prefetchHints,
slots: slotMetadata, slots: slotMetadata,
isRootLayout: route[4] === true,
} }
} }
......
import type { ComponentType } from 'react' import type { ComponentType } from 'react'
import { import type {
PrefetchHint, CacheNodeSeedData,
type CacheNodeSeedData, LoadingModuleData,
type LoadingModuleData,
} from '../../shared/lib/app-router-types' } from '../../shared/lib/app-router-types'
import type { PreloadCallbacks } from './types' import type { PreloadCallbacks } from './types'
import { import {
...@@ -42,7 +41,6 @@ import { ...@@ -42,7 +41,6 @@ import {
getConventionPathByType, getConventionPathByType,
isNextjsBuiltinFilePath, isNextjsBuiltinFilePath,
} from './segment-explorer-path' } from './segment-explorer-path'
import type { AppSegmentConfig } from '../../build/segment-config/app/app-segment-config'
/** /**
* Use the provided loader tree to create the React Component tree. * Use the provided loader tree to create the React Component tree.
...@@ -226,17 +224,6 @@ async function createComponentTreeInternal( ...@@ -226,17 +224,6 @@ async function createComponentTreeInternal(
}) })
: [] : []
const instantConfig = layoutOrPageMod
? (layoutOrPageMod as AppSegmentConfig).unstable_instant
: undefined
let prefetchHints = 0
if (instantConfig && typeof instantConfig === 'object') {
prefetchHints |= PrefetchHint.SubtreeHasInstant
if (instantConfig.prefetch === 'runtime') {
prefetchHints |= PrefetchHint.HasRuntimePrefetch
}
}
const [Forbidden, forbiddenStyles] = const [Forbidden, forbiddenStyles] =
authInterrupts && forbidden authInterrupts && forbidden
? await createComponentStylesAndScripts({ ? await createComponentStylesAndScripts({
...@@ -697,7 +684,6 @@ async function createComponentTreeInternal( ...@@ -697,7 +684,6 @@ async function createComponentTreeInternal(
parallelRouteCacheNodeSeedData, parallelRouteCacheNodeSeedData,
loadingData, loadingData,
isPossiblyPartialResponse, isPossiblyPartialResponse,
prefetchHints,
// No user-provided component, so no params will be accessed. Use the // No user-provided component, so no params will be accessed. Use the
// pre-resolved empty tracker. // pre-resolved empty tracker.
emptyVaryParamsAccumulator emptyVaryParamsAccumulator
...@@ -737,7 +723,6 @@ async function createComponentTreeInternal( ...@@ -737,7 +723,6 @@ async function createComponentTreeInternal(
parallelRouteCacheNodeSeedData, parallelRouteCacheNodeSeedData,
loadingData, loadingData,
true, true,
prefetchHints,
// force-dynamic postpones without rendering the component, so no params // force-dynamic postpones without rendering the component, so no params
// are accessed. The vary params are empty. // are accessed. The vary params are empty.
emptyVaryParamsAccumulator emptyVaryParamsAccumulator
...@@ -865,7 +850,6 @@ async function createComponentTreeInternal( ...@@ -865,7 +850,6 @@ async function createComponentTreeInternal(
parallelRouteCacheNodeSeedData, parallelRouteCacheNodeSeedData,
loadingData, loadingData,
isPossiblyPartialResponse, isPossiblyPartialResponse,
prefetchHints,
varyParamsAccumulator varyParamsAccumulator
) )
} else { } else {
...@@ -1080,7 +1064,6 @@ async function createComponentTreeInternal( ...@@ -1080,7 +1064,6 @@ async function createComponentTreeInternal(
parallelRouteCacheNodeSeedData, parallelRouteCacheNodeSeedData,
loadingData, loadingData,
isPossiblyPartialResponse, isPossiblyPartialResponse,
prefetchHints,
varyParamsAccumulator varyParamsAccumulator
) )
} }
...@@ -1232,7 +1215,6 @@ function createSeedData( ...@@ -1232,7 +1215,6 @@ function createSeedData(
parallelRoutes: Record<string, CacheNodeSeedData | null>, parallelRoutes: Record<string, CacheNodeSeedData | null>,
loading: LoadingModuleData | null, loading: LoadingModuleData | null,
isPossiblyPartialResponse: boolean, isPossiblyPartialResponse: boolean,
prefetchHints: number,
varyParamsAccumulator: VaryParamsAccumulator | null varyParamsAccumulator: VaryParamsAccumulator | null
): CacheNodeSeedData { ): CacheNodeSeedData {
if (loading !== null) { if (loading !== null) {
...@@ -1248,22 +1230,11 @@ function createSeedData( ...@@ -1248,22 +1230,11 @@ function createSeedData(
children: rsc, children: rsc,
}) })
} }
// Propagate SubtreeHasInstant from children so the root reflects the
// entire subtree.
// TODO: We should send the prefetch hints bitmask as part of the route tree,
// rather than the CacheNodeSeedData.
for (const key in parallelRoutes) {
const child = parallelRoutes[key]
if (child !== null) {
prefetchHints |= child[4] & PrefetchHint.SubtreeHasInstant
}
}
return [ return [
rsc, rsc,
parallelRoutes, parallelRoutes,
null, null,
isPossiblyPartialResponse, isPossiblyPartialResponse,
prefetchHints,
varyParamsAccumulator ? getVaryParamsThenable(varyParamsAccumulator) : null, varyParamsAccumulator ? getVaryParamsThenable(varyParamsAccumulator) : null,
] ]
} }
import type { LoaderTree } from '../lib/app-dir-module' import type { LoaderTree } from '../lib/app-dir-module'
import { import {
HasLoadingBoundary, PrefetchHint,
type FlightRouterState, type FlightRouterState,
} from '../../shared/lib/app-router-types' } from '../../shared/lib/app-router-types'
import type { GetDynamicParamFromSegment } from './app-render' import type { GetDynamicParamFromSegment } from './app-render'
import { addSearchParamsIfPageSegment } from '../../shared/lib/segment' import { addSearchParamsIfPageSegment } from '../../shared/lib/segment'
import type { AppSegmentConfig } from '../../build/segment-config/app/app-segment-config'
function createFlightRouterStateFromLoaderTreeImpl( async function createFlightRouterStateFromLoaderTreeImpl(
loaderTree: LoaderTree, loaderTree: LoaderTree,
getDynamicParamFromSegment: GetDynamicParamFromSegment, getDynamicParamFromSegment: GetDynamicParamFromSegment,
searchParams: any, searchParams: any,
includeHasLoadingBoundary: boolean,
didFindRootLayout: boolean didFindRootLayout: boolean
): FlightRouterState { ): Promise<FlightRouterState> {
const [segment, parallelRoutes, { layout, loading }] = loaderTree const [segment, parallelRoutes, { layout, loading, page }] = loaderTree
const dynamicParam = getDynamicParamFromSegment(loaderTree) const dynamicParam = getDynamicParamFromSegment(loaderTree)
const treeSegment = dynamicParam ? dynamicParam.treeSegment : segment const treeSegment = dynamicParam ? dynamicParam.treeSegment : segment
...@@ -22,83 +22,93 @@ function createFlightRouterStateFromLoaderTreeImpl( ...@@ -22,83 +22,93 @@ function createFlightRouterStateFromLoaderTreeImpl(
{}, {},
] ]
// Load the layout or page module to check for unstable_instant config
const mod = layout ? await layout[0]() : page ? await page[0]() : undefined
const instantConfig = mod
? (mod as AppSegmentConfig).unstable_instant
: undefined
let prefetchHints = 0
// Mark the first segment that has a layout as the "root" layout // Mark the first segment that has a layout as the "root" layout
if (!didFindRootLayout && typeof layout !== 'undefined') { if (!didFindRootLayout && typeof layout !== 'undefined') {
didFindRootLayout = true didFindRootLayout = true
segmentTree[4] = true prefetchHints |= PrefetchHint.IsRootLayout
}
if (instantConfig && typeof instantConfig === 'object') {
prefetchHints |= PrefetchHint.SubtreeHasInstant
if (instantConfig.prefetch === 'runtime') {
prefetchHints |= PrefetchHint.HasRuntimePrefetch
}
}
// Check if this segment has a loading boundary
if (loading) {
prefetchHints |= PrefetchHint.SegmentHasLoadingBoundary
} }
let childHasLoadingBoundary = false
const children: FlightRouterState[1] = {} const children: FlightRouterState[1] = {}
for (const parallelRouteKey in parallelRoutes) { for (const parallelRouteKey in parallelRoutes) {
const child = createFlightRouterStateFromLoaderTreeImpl( const child = await createFlightRouterStateFromLoaderTreeImpl(
parallelRoutes[parallelRouteKey], parallelRoutes[parallelRouteKey],
getDynamicParamFromSegment, getDynamicParamFromSegment,
searchParams, searchParams,
includeHasLoadingBoundary,
didFindRootLayout didFindRootLayout
) )
if ( // Propagate subtree flags from children
includeHasLoadingBoundary && if (child[4] !== undefined) {
child[5] !== HasLoadingBoundary.SubtreeHasNoLoadingBoundary prefetchHints |=
) { child[4] &
childHasLoadingBoundary = true (PrefetchHint.SubtreeHasInstant |
PrefetchHint.SubtreeHasLoadingBoundary)
// If a child has a loading boundary (either directly or in its subtree),
// propagate that as SubtreeHasLoadingBoundary to this segment.
if (
child[4] &
(PrefetchHint.SegmentHasLoadingBoundary |
PrefetchHint.SubtreeHasLoadingBoundary)
) {
prefetchHints |= PrefetchHint.SubtreeHasLoadingBoundary
}
} }
children[parallelRouteKey] = child children[parallelRouteKey] = child
} }
segmentTree[1] = children segmentTree[1] = children
if (includeHasLoadingBoundary) { if (prefetchHints !== 0) {
// During a route tree prefetch, the FlightRouterState includes whether a segmentTree[4] = prefetchHints
// tree has a loading boundary. The client uses this to determine if it can
// skip the data prefetch request — if `hasLoadingBoundary` is `false`, the
// data prefetch response will be empty, so there's no reason to request it.
// NOTE: It would be better to accumulate this while building the loader
// tree so we don't have to keep re-deriving it, but since this won't be
// once PPR is enabled everywhere, it's not that important.
segmentTree[5] = loading
? HasLoadingBoundary.SegmentHasLoadingBoundary
: childHasLoadingBoundary
? HasLoadingBoundary.SubtreeHasLoadingBoundary
: HasLoadingBoundary.SubtreeHasNoLoadingBoundary
} }
return segmentTree return segmentTree
} }
export function createFlightRouterStateFromLoaderTree( export async function createFlightRouterStateFromLoaderTree(
loaderTree: LoaderTree, loaderTree: LoaderTree,
getDynamicParamFromSegment: GetDynamicParamFromSegment, getDynamicParamFromSegment: GetDynamicParamFromSegment,
searchParams: any searchParams: any
) { ): Promise<FlightRouterState> {
const includeHasLoadingBoundary = false
const didFindRootLayout = false const didFindRootLayout = false
return createFlightRouterStateFromLoaderTreeImpl( return createFlightRouterStateFromLoaderTreeImpl(
loaderTree, loaderTree,
getDynamicParamFromSegment, getDynamicParamFromSegment,
searchParams, searchParams,
includeHasLoadingBoundary,
didFindRootLayout didFindRootLayout
) )
} }
export function createRouteTreePrefetch( export async function createRouteTreePrefetch(
loaderTree: LoaderTree, loaderTree: LoaderTree,
getDynamicParamFromSegment: GetDynamicParamFromSegment getDynamicParamFromSegment: GetDynamicParamFromSegment
): FlightRouterState { ): Promise<FlightRouterState> {
// Search params should not be added to page segment's cache key during a // Search params should not be added to page segment's cache key during a
// route tree prefetch request, because they do not affect the structure of // route tree prefetch request, because they do not affect the structure of
// the route. The client cache has its own logic to handle search params. // the route. The client cache has its own logic to handle search params.
const searchParams = {} const searchParams = {}
// During a route tree prefetch, we include `hasLoadingBoundary` in
// the response.
const includeHasLoadingBoundary = true
const didFindRootLayout = false const didFindRootLayout = false
return createFlightRouterStateFromLoaderTreeImpl( return createFlightRouterStateFromLoaderTreeImpl(
loaderTree, loaderTree,
getDynamicParamFromSegment, getDynamicParamFromSegment,
searchParams, searchParams,
includeHasLoadingBoundary,
didFindRootLayout didFindRootLayout
) )
} }
...@@ -1053,23 +1053,14 @@ function deserializeFromChunks<T>( ...@@ -1053,23 +1053,14 @@ function deserializeFromChunks<T>(
type SegmentData = { type SegmentData = {
node: React.ReactNode | null node: React.ReactNode | null
isPartial: boolean isPartial: boolean
prefetchHints: number
varyParams: VaryParamsThenable | null varyParams: VaryParamsThenable | null
} }
function createSegmentData(seedData: CacheNodeSeedData): SegmentData { function createSegmentData(seedData: CacheNodeSeedData): SegmentData {
const [ const [node, _parallelRoutesData, _unused, isPartial, varyParams] = seedData
node,
_parallelRoutesData,
_unused,
isPartial,
prefetchHints,
varyParams,
] = seedData
return { return {
node, node,
isPartial, isPartial,
prefetchHints,
varyParams, varyParams,
} }
} }
...@@ -1084,7 +1075,6 @@ function getCacheNodeSeedDataFromSegment( ...@@ -1084,7 +1075,6 @@ function getCacheNodeSeedDataFromSegment(
slots, slots,
/* unused (previously `loading`) */ null, /* unused (previously `loading`) */ null,
data.isPartial, data.isPartial,
data.prefetchHints,
data.varyParams, data.varyParams,
] ]
} }
......
...@@ -17,7 +17,7 @@ const validFixtures = [ ...@@ -17,7 +17,7 @@ const validFixtures = [
}, },
null, null,
null, null,
true, 0b10000, // PrefetchHint.IsRootLayout
], ],
[ [
['a', 'b', 'c', null], ['a', 'b', 'c', null],
...@@ -52,7 +52,7 @@ const invalidFixtures = [ ...@@ -52,7 +52,7 @@ const invalidFixtures = [
invalid: 'invalid', invalid: 'invalid',
}, },
], ],
// invalid isRootLayout // invalid refresh marker (number instead of string)
[ [
['a', 'b', 'c', null], ['a', 'b', 'c', null],
{ {
......
...@@ -75,7 +75,7 @@ export const flightRouterStateSchema: s.Describe<any> = s.tuple([ ...@@ -75,7 +75,7 @@ export const flightRouterStateSchema: s.Describe<any> = s.tuple([
]) ])
) )
), ),
s.optional(s.boolean()), s.optional(s.number()),
]) ])
export type ServerOnInstrumentationRequestError = ( export type ServerOnInstrumentationRequestError = (
......
...@@ -151,8 +151,11 @@ export async function walkTreeWithFlightRouterState({ ...@@ -151,8 +151,11 @@ export async function walkTreeWithFlightRouterState({
const routerState = parsedRequestHeaders.isRouteTreePrefetchRequest const routerState = parsedRequestHeaders.isRouteTreePrefetchRequest
? // Route tree prefetch requests contain some extra information ? // Route tree prefetch requests contain some extra information
createRouteTreePrefetch(loaderTreeToFilter, getDynamicParamFromSegment) await createRouteTreePrefetch(
: createFlightRouterStateFromLoaderTree( loaderTreeToFilter,
getDynamicParamFromSegment
)
: await createFlightRouterStateFromLoaderTree(
loaderTreeToFilter, loaderTreeToFilter,
getDynamicParamFromSegment, getDynamicParamFromSegment,
query query
...@@ -178,8 +181,11 @@ export async function walkTreeWithFlightRouterState({ ...@@ -178,8 +181,11 @@ export async function walkTreeWithFlightRouterState({
? flightRouterState[0] ? flightRouterState[0]
: actualSegment : actualSegment
const routerState = parsedRequestHeaders.isRouteTreePrefetchRequest const routerState = parsedRequestHeaders.isRouteTreePrefetchRequest
? createRouteTreePrefetch(loaderTreeToFilter, getDynamicParamFromSegment) ? await createRouteTreePrefetch(
: createFlightRouterStateFromLoaderTree( loaderTreeToFilter,
getDynamicParamFromSegment
)
: await createFlightRouterStateFromLoaderTree(
loaderTreeToFilter, loaderTreeToFilter,
getDynamicParamFromSegment, getDynamicParamFromSegment,
query query
...@@ -205,7 +211,7 @@ export async function walkTreeWithFlightRouterState({ ...@@ -205,7 +211,7 @@ export async function walkTreeWithFlightRouterState({
? flightRouterState[0] ? flightRouterState[0]
: actualSegment : actualSegment
const routerState = createFlightRouterStateFromLoaderTree( const routerState = await createFlightRouterStateFromLoaderTree(
// Create router state using the slice of the loaderTree // Create router state using the slice of the loaderTree
loaderTreeToFilter, loaderTreeToFilter,
getDynamicParamFromSegment, getDynamicParamFromSegment,
...@@ -325,7 +331,7 @@ export async function createFullTreeFlightDataForNavigation({ ...@@ -325,7 +331,7 @@ export async function createFullTreeFlightDataForNavigation({
getDynamicParamFromSegment, getDynamicParamFromSegment,
} = ctx } = ctx
const routerState = createFlightRouterStateFromLoaderTree( const routerState = await createFlightRouterStateFromLoaderTree(
loaderTree, loaderTree,
getDynamicParamFromSegment, getDynamicParamFromSegment,
query query
......
...@@ -131,13 +131,12 @@ export type FlightRouterState = [ ...@@ -131,13 +131,12 @@ export type FlightRouterState = [
* overloaded with concerns. * overloaded with concerns.
*/ */
refresh?: 'refetch' | 'inside-shared-layout' | 'metadata-only' | null, refresh?: 'refetch' | 'inside-shared-layout' | 'metadata-only' | null,
isRootLayout?: boolean,
/** /**
* Only present when responding to a tree prefetch request. Indicates whether * Bitmask of PrefetchHint flags. Encodes route structure metadata:
* there is a loading boundary somewhere in the tree. The client cache uses * root layout, loading boundaries, instant configs, and runtime prefetch
* this to determine if it can skip the data prefetch request. * hints. Only set when non-zero.
*/ */
hasLoadingBoundary?: HasLoadingBoundary, prefetchHints?: number,
] ]
/** /**
...@@ -152,24 +151,21 @@ export type FlightRouterState = [ ...@@ -152,24 +151,21 @@ export type FlightRouterState = [
*/ */
export type CompressedRefreshState = [url: string, renderedSearch: string] export type CompressedRefreshState = [url: string, renderedSearch: string]
export const enum HasLoadingBoundary {
// There is a loading boundary in this particular segment
SegmentHasLoadingBoundary = 1,
// There is a loading boundary somewhere in the subtree (but not in
// this segment)
SubtreeHasLoadingBoundary = 2,
// There is no loading boundary in this segment or any of its descendants
SubtreeHasNoLoadingBoundary = 3,
}
export const enum PrefetchHint { export const enum PrefetchHint {
// This segment has a runtime prefetch enabled (via unstable_instant with // This segment has a runtime prefetch enabled (via unstable_instant with
// prefetch: 'runtime'). Per-segment only, does not propagate to ancestors. // prefetch: 'runtime'). Per-segment only, does not propagate to ancestors.
HasRuntimePrefetch = 0b01, HasRuntimePrefetch = 0b00001,
// This segment or one of its descendants has an instant config defined // This segment or one of its descendants has an instant config defined
// (any truthy unstable_instant, regardless of prefetch mode). Propagates // (any truthy unstable_instant, regardless of prefetch mode). Propagates
// upward so the root segment reflects the entire subtree. // upward so the root segment reflects the entire subtree.
SubtreeHasInstant = 0b10, SubtreeHasInstant = 0b00010,
// This segment itself has a loading.tsx boundary.
SegmentHasLoadingBoundary = 0b00100,
// A descendant segment (but not this one) has a loading.tsx boundary.
// Propagates upward so the root reflects the entire subtree.
SubtreeHasLoadingBoundary = 0b01000,
// This segment is the root layout of the application.
IsRootLayout = 0b10000,
} }
/** /**
...@@ -203,8 +199,6 @@ export type CacheNodeSeedData = [ ...@@ -203,8 +199,6 @@ export type CacheNodeSeedData = [
// TODO: This field is no longer used. Remove it. // TODO: This field is no longer used. Remove it.
loading: null, loading: null,
isPartial: boolean, isPartial: boolean,
/** TODO: this doesn't feel like it belongs here, because it's only used during build, in `collectSegmentData` */
prefetchHints: number,
/** /**
* A thenable that resolves to the set of route params this segment accessed * A thenable that resolves to the set of route params this segment accessed
* during server rendering. Used by the client router to determine cache key * during server rendering. Used by the client router to determine cache key
......
...@@ -212,7 +212,7 @@ describe('app dir - prefetching', () => { ...@@ -212,7 +212,7 @@ describe('app dir - prefetching', () => {
'prefetch-auto', 'prefetch-auto',
{ {
children: [ children: [
['slug', 'justputit', 'd'], ['slug', 'justputit', 'd', null],
{ children: ['__PAGE__', {}] }, { children: ['__PAGE__', {}] },
], ],
}, },
...@@ -220,7 +220,7 @@ describe('app dir - prefetching', () => { ...@@ -220,7 +220,7 @@ describe('app dir - prefetching', () => {
}, },
null, null,
null, null,
true, 16, // PrefetchHint.IsRootLayout
]) ])
) )
const response = await next.fetch(`/prefetch-auto/justputit?_rsc=dcqtr`, { const response = await next.fetch(`/prefetch-auto/justputit?_rsc=dcqtr`, {
...@@ -255,7 +255,7 @@ describe('app dir - prefetching', () => { ...@@ -255,7 +255,7 @@ describe('app dir - prefetching', () => {
}, },
null, null,
null, null,
true, 16, // PrefetchHint.IsRootLayout
]) ])
) )
......
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