Skip to content

Commit

Permalink
Only wait for metadata when dynamicIO experiment is on (#70192)
Browse files Browse the repository at this point in the history
waiting for metadata is only necessary when `dynamicIO` is enabled. In
the long run we will get rid of this waiting anyway when we have async
dynamic APIs so we condition this behavior to be only when dynamicIO is
on for now
  • Loading branch information
gnoff authored Sep 17, 2024
1 parent 727e625 commit 3b5bae4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ async function createComponentTreeInternal({
notFound={
NotFoundComponent ? (
<Segment
isDynamicIO={experimental.dynamicIO}
isStaticGeneration={isStaticGeneration}
ready={getMetadataReady}
>
Expand Down Expand Up @@ -500,6 +501,7 @@ async function createComponentTreeInternal({
actualSegment,
<Segment
key={cacheNodeKey}
isDynamicIO={experimental.dynamicIO}
isStaticGeneration={isStaticGeneration}
ready={getMetadataReady}
>
Expand Down Expand Up @@ -530,6 +532,7 @@ async function createComponentTreeInternal({
return [
actualSegment,
<Segment
isDynamicIO={experimental.dynamicIO}
key={cacheNodeKey}
isStaticGeneration={isStaticGeneration}
ready={getMetadataReady}
Expand Down Expand Up @@ -585,6 +588,7 @@ async function createComponentTreeInternal({
<React.Fragment key={cacheNodeKey}>
<MetadataOutlet ready={getMetadataReady} />
<Segment
isDynamicIO={experimental.dynamicIO}
isStaticGeneration={isStaticGeneration}
ready={getMetadataReady}
>
Expand All @@ -608,6 +612,7 @@ async function createComponentTreeInternal({
// a lazy hole rather than null
<Segment
key={cacheNodeKey}
isDynamicIO={experimental.dynamicIO}
isStaticGeneration={isStaticGeneration}
ready={getMetadataReady}
>
Expand Down Expand Up @@ -636,15 +641,17 @@ async function MetadataOutlet({
}

async function Segment({
isDynamicIO,
isStaticGeneration,
ready,
children,
}: {
isDynamicIO: boolean
isStaticGeneration: boolean
ready?: () => Promise<void>
children: React.ReactNode
}) {
if (isStaticGeneration && ready) {
if (isDynamicIO && isStaticGeneration && ready) {
// During static generation we wait for metadata to complete before rendering segments.
// This is slower but it allows us to ensure that metadata is finished before we start
// rendering the segment which can synchronously abort the render in certain circumstances
Expand Down
2 changes: 1 addition & 1 deletion test/lib/e2e-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type { NextInstance }
// this is due to current --turbo test have a lot of tests fails with timeouts, ends up the whole
// test job exceeds the 6 hours limit.
let testTimeout = shouldRunTurboDevTest()
? (240 * 1000) / 4
? (240 * 1000) / 2
: (process.platform === 'win32' ? 240 : 120) * 1000

if (process.env.NEXT_E2E_TEST_TIMEOUT) {
Expand Down

0 comments on commit 3b5bae4

Please sign in to comment.