Unverified Commit 899b473e authored by Andrew Clark's avatar Andrew Clark Committed by GitHub

Remove Segment from CacheNodeSeedData (#85080)

We don't need to send the segment as part of the CacheNodeSeedData
because it's already in the FlightRouterState, which it always
accompanies. Eventually these two types should be unified completely (in
the server response, at least).
parent 4955c5dd
...@@ -892,5 +892,8 @@ ...@@ -892,5 +892,8 @@
"891": "Failed to read build paths file \"%s\": %s", "891": "Failed to read build paths file \"%s\": %s",
"892": "Failed to resolve glob pattern \"%s\": %s", "892": "Failed to resolve glob pattern \"%s\": %s",
"893": "The \"sassOptions.functions\" option is not supported when using Turbopack. Custom Sass functions are only available with webpack. Please remove the \"functions\" property from your sassOptions in %s.", "893": "The \"sassOptions.functions\" option is not supported when using Turbopack. Custom Sass functions are only available with webpack. Please remove the \"functions\" property from your sassOptions in %s.",
"894": "Param %s not found in childrenRouteParamSegments %s" "894": "Param %s not found in childrenRouteParamSegments %s",
"895": "Invalid React HTML document. Should start with doctype prefix.",
"896": "oops",
"897": "Expected HTML document to start with doctype prefix"
} }
...@@ -84,8 +84,8 @@ export function handleAliasedPrefetchEntry( ...@@ -84,8 +84,8 @@ export function handleAliasedPrefetchEntry(
// loading state and not the actual parallel route seed data. // loading state and not the actual parallel route seed data.
if (isRootRender && seedData) { if (isRootRender && seedData) {
// Fill in the cache with the new loading / rsc data // Fill in the cache with the new loading / rsc data
const rsc = seedData[1] const rsc = seedData[0]
const loading = seedData[3] const loading = seedData[2]
newCache.loading = loading newCache.loading = loading
newCache.rsc = rsc newCache.rsc = rsc
...@@ -153,8 +153,8 @@ export function handleAliasedPrefetchEntry( ...@@ -153,8 +153,8 @@ export function handleAliasedPrefetchEntry(
function hasLoadingComponentInSeedData(seedData: CacheNodeSeedData | null) { function hasLoadingComponentInSeedData(seedData: CacheNodeSeedData | null) {
if (!seedData) return false if (!seedData) return false
const parallelRoutes = seedData[2] const parallelRoutes = seedData[1]
const loading = seedData[3] const loading = seedData[2]
if (loading) { if (loading) {
return true return true
...@@ -187,15 +187,15 @@ function fillNewTreeWithOnlyLoadingSegments( ...@@ -187,15 +187,15 @@ function fillNewTreeWithOnlyLoadingSegments(
const cacheKey = createRouterCacheKey(segmentForParallelRoute) const cacheKey = createRouterCacheKey(segmentForParallelRoute)
const parallelSeedData = const parallelSeedData =
cacheNodeSeedData !== null && cacheNodeSeedData[2][key] !== undefined cacheNodeSeedData !== null && cacheNodeSeedData[1][key] !== undefined
? cacheNodeSeedData[2][key] ? cacheNodeSeedData[1][key]
: null : null
let newCacheNode: CacheNode let newCacheNode: CacheNode
if (parallelSeedData !== null) { if (parallelSeedData !== null) {
// New data was sent from the server. // New data was sent from the server.
const rsc = parallelSeedData[1] const rsc = parallelSeedData[0]
const loading = parallelSeedData[3] const loading = parallelSeedData[2]
newCacheNode = { newCacheNode = {
lazyData: null, lazyData: null,
// copy the layout but null the page segment as that's not meant to be used // copy the layout but null the page segment as that's not meant to be used
......
...@@ -18,8 +18,8 @@ export function applyFlightData( ...@@ -18,8 +18,8 @@ export function applyFlightData(
} }
if (isRootRender) { if (isRootRender) {
const rsc = seedData[1] const rsc = seedData[0]
const loading = seedData[3] const loading = seedData[2]
cache.loading = loading cache.loading = loading
cache.rsc = rsc cache.rsc = rsc
// This is a PPR-only field. When PPR is enabled, we shouldn't hit // This is a PPR-only field. When PPR is enabled, we shouldn't hit
......
...@@ -36,7 +36,7 @@ describe('createInitialRouterState', () => { ...@@ -36,7 +36,7 @@ describe('createInitialRouterState', () => {
const state = createInitialRouterState({ const state = createInitialRouterState({
navigatedAt, navigatedAt,
initialFlightData: [[initialTree, ['', children, {}, null]]], initialFlightData: [[initialTree, [children, {}, null]]],
initialCanonicalUrlParts: initialCanonicalUrl.split('/'), initialCanonicalUrlParts: initialCanonicalUrl.split('/'),
initialRenderedSearch: '', initialRenderedSearch: '',
initialParallelRoutes, initialParallelRoutes,
...@@ -45,7 +45,7 @@ describe('createInitialRouterState', () => { ...@@ -45,7 +45,7 @@ describe('createInitialRouterState', () => {
const state2 = createInitialRouterState({ const state2 = createInitialRouterState({
navigatedAt, navigatedAt,
initialFlightData: [[initialTree, ['', children, {}, null]]], initialFlightData: [[initialTree, [children, {}, null]]],
initialCanonicalUrlParts: initialCanonicalUrl.split('/'), initialCanonicalUrlParts: initialCanonicalUrl.split('/'),
initialRenderedSearch: '', initialRenderedSearch: '',
initialParallelRoutes, initialParallelRoutes,
......
...@@ -41,8 +41,8 @@ export function createInitialRouterState({ ...@@ -41,8 +41,8 @@ export function createInitialRouterState({
} = normalizedFlightData } = normalizedFlightData
// For the SSR render, seed data should always be available (we only send back a `null` response // For the SSR render, seed data should always be available (we only send back a `null` response
// in the case of a `loading` segment, pre-PPR.) // in the case of a `loading` segment, pre-PPR.)
const rsc = initialSeedData?.[1] const rsc = initialSeedData?.[0]
const loading = initialSeedData?.[3] ?? null const loading = initialSeedData?.[2] ?? null
const cache: CacheNode = { const cache: CacheNode = {
lazyData: null, lazyData: null,
......
...@@ -9,14 +9,7 @@ const getFlightData = (): NormalizedFlightData[] => { ...@@ -9,14 +9,7 @@ const getFlightData = (): NormalizedFlightData[] => {
segmentPath: ['children', 'linking', 'children', 'about'], segmentPath: ['children', 'linking', 'children', 'about'],
segment: 'about', segment: 'about',
tree: ['about', { children: ['', {}] }], tree: ['about', { children: ['', {}] }],
seedData: [ seedData: [<h1>SubTreeData Injected!</h1>, {}, null, false, false],
'about',
<h1>SubTreeData Injected!</h1>,
{},
null,
false,
false,
],
head: null, head: null,
isHeadPartial: false, isHeadPartial: false,
isRootRender: false, isRootRender: false,
......
...@@ -58,16 +58,14 @@ function fillCacheHelper( ...@@ -58,16 +58,14 @@ function fillCacheHelper(
!childCacheNode.lazyData || !childCacheNode.lazyData ||
childCacheNode === existingChildCacheNode) childCacheNode === existingChildCacheNode)
) { ) {
const incomingSegment = cacheNodeSeedData[0] const rsc = cacheNodeSeedData[0]
const rsc = cacheNodeSeedData[1] const loading = cacheNodeSeedData[2]
const loading = cacheNodeSeedData[3]
childCacheNode = { childCacheNode = {
lazyData: null, lazyData: null,
// When `fillLazyItems` is false, we only want to fill the RSC data for the layout, // When `fillLazyItems` is false, we only want to fill the RSC data for the layout,
// not the page segment. // not the page segment.
rsc: rsc: fillLazyItems || segment !== PAGE_SEGMENT_KEY ? rsc : null,
fillLazyItems || incomingSegment !== PAGE_SEGMENT_KEY ? rsc : null,
prefetchRsc: null, prefetchRsc: null,
head: null, head: null,
prefetchHead: null, prefetchHead: null,
......
...@@ -35,8 +35,8 @@ export function fillLazyItemsTillLeafWithHead( ...@@ -35,8 +35,8 @@ export function fillLazyItemsTillLeafWithHead(
// in the response format, so that we don't have to send the keys twice. // in the response format, so that we don't have to send the keys twice.
// Then the client can convert them into separate representations. // Then the client can convert them into separate representations.
const parallelSeedData = const parallelSeedData =
cacheNodeSeedData !== null && cacheNodeSeedData[2][key] !== undefined cacheNodeSeedData !== null && cacheNodeSeedData[1][key] !== undefined
? cacheNodeSeedData[2][key] ? cacheNodeSeedData[1][key]
: null : null
if (existingCache) { if (existingCache) {
const existingParallelRoutesCacheNode = const existingParallelRoutesCacheNode =
...@@ -47,8 +47,8 @@ export function fillLazyItemsTillLeafWithHead( ...@@ -47,8 +47,8 @@ export function fillLazyItemsTillLeafWithHead(
let newCacheNode: CacheNode let newCacheNode: CacheNode
if (parallelSeedData !== null) { if (parallelSeedData !== null) {
// New data was sent from the server. // New data was sent from the server.
const seedNode = parallelSeedData[1] const seedNode = parallelSeedData[0]
const loading = parallelSeedData[3] const loading = parallelSeedData[2]
newCacheNode = { newCacheNode = {
lazyData: null, lazyData: null,
rsc: seedNode, rsc: seedNode,
...@@ -99,8 +99,8 @@ export function fillLazyItemsTillLeafWithHead( ...@@ -99,8 +99,8 @@ export function fillLazyItemsTillLeafWithHead(
let newCacheNode: CacheNode let newCacheNode: CacheNode
if (parallelSeedData !== null) { if (parallelSeedData !== null) {
// New data was sent from the server. // New data was sent from the server.
const seedNode = parallelSeedData[1] const seedNode = parallelSeedData[0]
const loading = parallelSeedData[3] const loading = parallelSeedData[2]
newCacheNode = { newCacheNode = {
lazyData: null, lazyData: null,
rsc: seedNode, rsc: seedNode,
......
...@@ -11,7 +11,7 @@ const getFlightData = (): NormalizedFlightData[] => { ...@@ -11,7 +11,7 @@ const getFlightData = (): NormalizedFlightData[] => {
segmentPath: ['children', 'linking', 'children', 'about'], segmentPath: ['children', 'linking', 'children', 'about'],
segment: 'about', segment: 'about',
tree: ['about', { children: ['', {}] }], tree: ['about', { children: ['', {}] }],
seedData: ['about', <h1>About Page!</h1>, {}, null, false, false], seedData: [<h1>About Page!</h1>, {}, null, false, false],
head: null, head: null,
isHeadPartial: false, isHeadPartial: false,
isRootRender: false, isRootRender: false,
......
...@@ -136,7 +136,7 @@ function updateCacheNodeOnNavigation( ...@@ -136,7 +136,7 @@ function updateCacheNodeOnNavigation(
// Diff the old and new trees to reuse the shared layouts. // Diff the old and new trees to reuse the shared layouts.
const oldRouterStateChildren = oldRouterState[1] const oldRouterStateChildren = oldRouterState[1]
const newRouterStateChildren = newRouterState[1] const newRouterStateChildren = newRouterState[1]
const prefetchDataChildren = prefetchData !== null ? prefetchData[2] : null const prefetchDataChildren = prefetchData !== null ? prefetchData[1] : null
if (!didFindRootLayout) { if (!didFindRootLayout) {
// 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
...@@ -529,14 +529,14 @@ function createCacheNodeOnNavigation( ...@@ -529,14 +529,14 @@ function createCacheNodeOnNavigation(
// There's no existing CacheNode for this segment, but we do have prefetch // There's no existing CacheNode for this segment, but we do have prefetch
// data. If the prefetch data is fully static (i.e. does not contain any // data. If the prefetch data is fully static (i.e. does not contain any
// dynamic holes), we don't need to request it from the server. // dynamic holes), we don't need to request it from the server.
rsc = prefetchData[1] rsc = prefetchData[0]
loading = prefetchData[3] loading = prefetchData[2]
head = isLeafSegment ? possiblyPartialPrefetchHead : null head = isLeafSegment ? possiblyPartialPrefetchHead : null
// Even though we're accessing the data from the prefetch cache, this is // Even though we're accessing the data from the prefetch cache, this is
// conceptually a new segment, not a reused one. So we should update the // conceptually a new segment, not a reused one. So we should update the
// navigatedAt timestamp. // navigatedAt timestamp.
cacheNodeNavigatedAt = navigatedAt cacheNodeNavigatedAt = navigatedAt
const isPrefetchRscPartial = prefetchData[4] const isPrefetchRscPartial = prefetchData[3]
if ( if (
// Check if the segment data is partial // Check if the segment data is partial
isPrefetchRscPartial || isPrefetchRscPartial ||
...@@ -577,7 +577,7 @@ function createCacheNodeOnNavigation( ...@@ -577,7 +577,7 @@ function createCacheNodeOnNavigation(
// We already have a full segment we can render, so we don't need to request a // We already have a full segment we can render, so we don't need to request a
// new one from the server. Keep traversing down the tree until we reach // new one from the server. Keep traversing down the tree until we reach
// something that requires a dynamic request. // something that requires a dynamic request.
const prefetchDataChildren = prefetchData !== null ? prefetchData[2] : null const prefetchDataChildren = prefetchData !== null ? prefetchData[1] : null
const taskChildren = new Map() const taskChildren = new Map()
const existingCacheNodeChildren = const existingCacheNodeChildren =
existingCacheNode !== undefined ? existingCacheNode.parallelRoutes : null existingCacheNode !== undefined ? existingCacheNode.parallelRoutes : null
...@@ -922,7 +922,7 @@ function finishTaskUsingDynamicDataPayload( ...@@ -922,7 +922,7 @@ function finishTaskUsingDynamicDataPayload(
// The server returned more data than we need to finish the task. Skip over // The server returned more data than we need to finish the task. Skip over
// the extra segments until we reach the leaf task node. // the extra segments until we reach the leaf task node.
const serverChildren = serverRouterState[1] const serverChildren = serverRouterState[1]
const dynamicDataChildren = dynamicData[2] const dynamicDataChildren = dynamicData[1]
for (const parallelRouteKey in serverRouterState) { for (const parallelRouteKey in serverRouterState) {
const serverRouterStateChild: FlightRouterState = const serverRouterStateChild: FlightRouterState =
...@@ -965,7 +965,7 @@ function createPendingCacheNode( ...@@ -965,7 +965,7 @@ function createPendingCacheNode(
scrollableSegmentsResult: Array<FlightSegmentPath> scrollableSegmentsResult: Array<FlightSegmentPath>
): ReadyCacheNode { ): ReadyCacheNode {
const routerStateChildren = routerState[1] const routerStateChildren = routerState[1]
const prefetchDataChildren = prefetchData !== null ? prefetchData[2] : null const prefetchDataChildren = prefetchData !== null ? prefetchData[1] : null
const parallelRoutes = new Map() const parallelRoutes = new Map()
for (let parallelRouteKey in routerStateChildren) { for (let parallelRouteKey in routerStateChildren) {
...@@ -1012,7 +1012,7 @@ function createPendingCacheNode( ...@@ -1012,7 +1012,7 @@ function createPendingCacheNode(
scrollableSegmentsResult.push(segmentPath) scrollableSegmentsResult.push(segmentPath)
} }
const maybePrefetchRsc = prefetchData !== null ? prefetchData[1] : null const maybePrefetchRsc = prefetchData !== null ? prefetchData[0] : null
return { return {
lazyData: null, lazyData: null,
parallelRoutes: parallelRoutes, parallelRoutes: parallelRoutes,
...@@ -1030,7 +1030,7 @@ function createPendingCacheNode( ...@@ -1030,7 +1030,7 @@ function createPendingCacheNode(
// we do for the segment data and head. // we do for the segment data and head.
loading: loading:
prefetchData !== null prefetchData !== null
? (prefetchData[3] ?? null) ? (prefetchData[2] ?? null)
: // If we don't have a prefetch, then we don't know if there's a loading component. : // If we don't have a prefetch, then we don't know if there's a loading component.
// We'll fulfill it based on the dynamic response, just like `rsc` and `head`. // We'll fulfill it based on the dynamic response, just like `rsc` and `head`.
createDeferredRsc<LoadingModuleData>(), createDeferredRsc<LoadingModuleData>(),
...@@ -1059,7 +1059,7 @@ function finishPendingCacheNode( ...@@ -1059,7 +1059,7 @@ function finishPendingCacheNode(
// data promise to `null` to trigger a lazy fetch during render. // data promise to `null` to trigger a lazy fetch during render.
const taskStateChildren = taskState[1] const taskStateChildren = taskState[1]
const serverStateChildren = serverState[1] const serverStateChildren = serverState[1]
const dataChildren = dynamicData[2] const dataChildren = dynamicData[1]
// The router state that we traverse the tree with (taskState) is the same one // The router state that we traverse the tree with (taskState) is the same one
// that we used to construct the pending Cache Node tree. That way we're sure // that we used to construct the pending Cache Node tree. That way we're sure
...@@ -1120,7 +1120,7 @@ function finishPendingCacheNode( ...@@ -1120,7 +1120,7 @@ function finishPendingCacheNode(
// Use the dynamic data from the server to fulfill the deferred RSC promise // Use the dynamic data from the server to fulfill the deferred RSC promise
// on the Cache Node. // on the Cache Node.
const rsc = cacheNode.rsc const rsc = cacheNode.rsc
const dynamicSegmentData = dynamicData[1] const dynamicSegmentData = dynamicData[0]
if (rsc === null) { if (rsc === null) {
// This is a lazy cache node. We can overwrite it. This is only safe // This is a lazy cache node. We can overwrite it. This is only safe
// because we know that the LayoutRouter suspends if `rsc` is `null`. // because we know that the LayoutRouter suspends if `rsc` is `null`.
...@@ -1139,7 +1139,7 @@ function finishPendingCacheNode( ...@@ -1139,7 +1139,7 @@ function finishPendingCacheNode(
// Fulfill it using the dynamic response so that we can display the loading boundary. // Fulfill it using the dynamic response so that we can display the loading boundary.
const loading = cacheNode.loading const loading = cacheNode.loading
if (isDeferredRsc(loading)) { if (isDeferredRsc(loading)) {
const dynamicLoading = dynamicData[3] const dynamicLoading = dynamicData[2]
loading.resolve(dynamicLoading, debugInfo) loading.resolve(dynamicLoading, debugInfo)
} }
......
...@@ -108,8 +108,8 @@ export function refreshReducer( ...@@ -108,8 +108,8 @@ export function refreshReducer(
// Handles case where prefetch only returns the router tree patch without rendered components. // Handles case where prefetch only returns the router tree patch without rendered components.
if (cacheNodeSeedData !== null) { if (cacheNodeSeedData !== null) {
const rsc = cacheNodeSeedData[1] const rsc = cacheNodeSeedData[0]
const loading = cacheNodeSeedData[3] const loading = cacheNodeSeedData[2]
cache.rsc = rsc cache.rsc = rsc
cache.prefetchRsc = null cache.prefetchRsc = null
cache.loading = loading cache.loading = loading
......
...@@ -375,11 +375,11 @@ export function serverActionReducer( ...@@ -375,11 +375,11 @@ export function serverActionReducer(
// The server sent back RSC data for the server action, so we need to apply it to the cache. // The server sent back RSC data for the server action, so we need to apply it to the cache.
if (cacheNodeSeedData !== null) { if (cacheNodeSeedData !== null) {
const rsc = cacheNodeSeedData[1] const rsc = cacheNodeSeedData[0]
const cache: CacheNode = createEmptyCacheNode() const cache: CacheNode = createEmptyCacheNode()
cache.rsc = rsc cache.rsc = rsc
cache.prefetchRsc = null cache.prefetchRsc = null
cache.loading = cacheNodeSeedData[3] cache.loading = cacheNodeSeedData[2]
fillLazyItemsTillLeafWithHead( fillLazyItemsTillLeafWithHead(
navigatedAt, navigatedAt,
cache, cache,
......
...@@ -1989,6 +1989,7 @@ function writeDynamicRenderResponseIntoCache( ...@@ -1989,6 +1989,7 @@ function writeDynamicRenderResponseIntoCache(
fetchStrategy, fetchStrategy,
route, route,
staleAt, staleAt,
flightData.tree,
seedData, seedData,
isResponsePartial, isResponsePartial,
cacheKey, cacheKey,
...@@ -2044,6 +2045,7 @@ function writeSeedDataIntoCache( ...@@ -2044,6 +2045,7 @@ function writeSeedDataIntoCache(
| FetchStrategy.Full, | FetchStrategy.Full,
route: FulfilledRouteCacheEntry, route: FulfilledRouteCacheEntry,
staleAt: number, staleAt: number,
flightRouterState: FlightRouterState,
seedData: CacheNodeSeedData, seedData: CacheNodeSeedData,
isResponsePartial: boolean, isResponsePartial: boolean,
cacheKey: SegmentCacheKey, cacheKey: SegmentCacheKey,
...@@ -2058,8 +2060,8 @@ function writeSeedDataIntoCache( ...@@ -2058,8 +2060,8 @@ function writeSeedDataIntoCache(
// want to treat a dynamic response as if it were static. The two examples // want to treat a dynamic response as if it were static. The two examples
// where this happens are <Link prefetch={true}> (which implicitly opts // where this happens are <Link prefetch={true}> (which implicitly opts
// dynamic data into being static) and when prefetching a PPR-disabled route // dynamic data into being static) and when prefetching a PPR-disabled route
const rsc = seedData[1] const rsc = seedData[0]
const loading = seedData[3] const loading = seedData[2]
const isPartial = rsc === null || isResponsePartial const isPartial = rsc === null || isResponsePartial
// We should only write into cache entries that are owned by us. Or create // We should only write into cache entries that are owned by us. Or create
...@@ -2110,36 +2112,38 @@ function writeSeedDataIntoCache( ...@@ -2110,36 +2112,38 @@ function writeSeedDataIntoCache(
} }
} }
// Recursively write the child data into the cache. // Recursively write the child data into the cache.
const seedDataChildren = seedData[2] const flightRouterStateChildren = flightRouterState[1]
if (seedDataChildren !== null) { const seedDataChildren = seedData[1]
for (const parallelRouteKey in seedDataChildren) { for (const parallelRouteKey in flightRouterStateChildren) {
const childSeedData = seedDataChildren[parallelRouteKey] const childFlightRouterState = flightRouterStateChildren[parallelRouteKey]
if (childSeedData !== null) { const childSeedData: CacheNodeSeedData | null | void =
const childSegment = childSeedData[0] seedDataChildren[parallelRouteKey]
const childRequestKeyPart = createSegmentRequestKeyPart(childSegment) if (childSeedData !== null && childSeedData !== undefined) {
const childRequestKey = appendSegmentRequestKeyPart( const childSegment = childFlightRouterState[0]
requestKey, const childRequestKeyPart = createSegmentRequestKeyPart(childSegment)
parallelRouteKey, const childRequestKey = appendSegmentRequestKeyPart(
childRequestKeyPart requestKey,
) parallelRouteKey,
const childCacheKey = appendSegmentCacheKeyPart( childRequestKeyPart
cacheKey, )
parallelRouteKey, const childCacheKey = appendSegmentCacheKeyPart(
createSegmentCacheKeyPart(childRequestKeyPart, childSegment) cacheKey,
) parallelRouteKey,
writeSeedDataIntoCache( createSegmentCacheKeyPart(childRequestKeyPart, childSegment)
now, )
task, writeSeedDataIntoCache(
fetchStrategy, now,
route, task,
staleAt, fetchStrategy,
childSeedData, route,
isResponsePartial, staleAt,
childCacheKey, childFlightRouterState,
childRequestKey, childSeedData,
entriesOwnedByCurrentTask isResponsePartial,
) childCacheKey,
} childRequestKey,
entriesOwnedByCurrentTask
)
} }
} }
} }
......
...@@ -399,14 +399,7 @@ function readRenderSnapshotFromCache( ...@@ -399,14 +399,7 @@ function readRenderSnapshotFromCache(
null, null,
tree.isRootLayout, tree.isRootLayout,
], ],
seedData: [ seedData: [rsc, childSeedDatas, loading, isPartial, hasRuntimePrefetch],
segment,
rsc,
childSeedDatas,
loading,
isPartial,
hasRuntimePrefetch,
],
} }
} }
......
...@@ -1278,7 +1278,6 @@ async function getErrorRSCPayload( ...@@ -1278,7 +1278,6 @@ async function getErrorRSCPayload(
// For metadata notFound error there's no global not found boundary on top // For metadata notFound error there's no global not found boundary on top
// so we create a not found page with AppRouter // so we create a not found page with AppRouter
const seedData: CacheNodeSeedData = [ const seedData: CacheNodeSeedData = [
initialTree[0],
createElement( createElement(
'html', 'html',
{ {
......
...@@ -254,7 +254,7 @@ function collectSegmentDataImpl( ...@@ -254,7 +254,7 @@ function collectSegmentDataImpl(
let slotMetadata: { [parallelRouteKey: string]: TreePrefetch } | null = null let slotMetadata: { [parallelRouteKey: string]: TreePrefetch } | null = null
const children = route[1] const children = route[1]
const seedDataChildren = seedData !== null ? seedData[2] : null const seedDataChildren = seedData !== null ? seedData[1] : null
for (const parallelRouteKey in children) { for (const parallelRouteKey in children) {
const childRoute = children[parallelRouteKey] const childRoute = children[parallelRouteKey]
const childSegment = childRoute[0] const childSegment = childRoute[0]
...@@ -281,7 +281,7 @@ function collectSegmentDataImpl( ...@@ -281,7 +281,7 @@ function collectSegmentDataImpl(
slotMetadata[parallelRouteKey] = childTree slotMetadata[parallelRouteKey] = childTree
} }
const hasRuntimePrefetch = seedData !== null ? seedData[5] : false const hasRuntimePrefetch = seedData !== null ? seedData[4] : false
if (seedData !== null) { if (seedData !== null) {
// Spawn a task to write the segment data to a new Flight stream. // Spawn a task to write the segment data to a new Flight stream.
...@@ -337,8 +337,8 @@ async function renderSegmentPrefetch( ...@@ -337,8 +337,8 @@ async function renderSegmentPrefetch(
// Render the segment data to a stream. // Render the segment data to a stream.
// In the future, this is where we can include additional metadata, like the // In the future, this is where we can include additional metadata, like the
// stale time and cache tags. // stale time and cache tags.
const rsc = seedData[1] const rsc = seedData[0]
const loading = seedData[3] const loading = seedData[2]
const segmentPrefetch: SegmentPrefetch = { const segmentPrefetch: SegmentPrefetch = {
buildId, buildId,
rsc, rsc,
......
...@@ -415,7 +415,6 @@ async function createComponentTreeInternal( ...@@ -415,7 +415,6 @@ async function createComponentTreeInternal(
} }
// Resolve the segment param // Resolve the segment param
const actualSegment = segmentParam ? segmentParam.treeSegment : segment
const isSegmentViewEnabled = !!ctx.renderOpts.dev const isSegmentViewEnabled = !!ctx.renderOpts.dev
const dir = const dir =
(process.env.NEXT_RUNTIME === 'edge' (process.env.NEXT_RUNTIME === 'edge'
...@@ -674,7 +673,6 @@ async function createComponentTreeInternal( ...@@ -674,7 +673,6 @@ async function createComponentTreeInternal(
// When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component // When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component
if (!MaybeComponent) { if (!MaybeComponent) {
return [ return [
actualSegment,
createElement( createElement(
Fragment, Fragment,
{ {
...@@ -708,7 +706,6 @@ async function createComponentTreeInternal( ...@@ -708,7 +706,6 @@ async function createComponentTreeInternal(
experimental.isRoutePPREnabled experimental.isRoutePPREnabled
) { ) {
return [ return [
actualSegment,
createElement( createElement(
Fragment, Fragment,
{ {
...@@ -812,7 +809,6 @@ async function createComponentTreeInternal( ...@@ -812,7 +809,6 @@ async function createComponentTreeInternal(
: pageElement : pageElement
return [ return [
actualSegment,
createElement( createElement(
Fragment, Fragment,
{ {
...@@ -1022,7 +1018,6 @@ async function createComponentTreeInternal( ...@@ -1022,7 +1018,6 @@ async function createComponentTreeInternal(
// For layouts we just render the component // For layouts we just render the component
return [ return [
actualSegment,
wrappedSegmentNode, wrappedSegmentNode,
parallelRouteCacheNodeSeedData, parallelRouteCacheNodeSeedData,
loadingData, loadingData,
......
...@@ -221,7 +221,6 @@ export type FlightSegmentPath = ...@@ -221,7 +221,6 @@ export type FlightSegmentPath =
* likely change. * likely change.
*/ */
export type CacheNodeSeedData = [ export type CacheNodeSeedData = [
segment: Segment,
node: React.ReactNode | null, node: React.ReactNode | null,
parallelRoutes: { parallelRoutes: {
[parallelRouterKey: string]: CacheNodeSeedData | null [parallelRouterKey: string]: CacheNodeSeedData | null
......
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