File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/next/src/server/stream-utils Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ import type { ReactDOMServerReadableStream } from 'react-dom/server'
22import { getTracer } from '../lib/trace/tracer'
33import { AppRenderSpan } from '../lib/trace/constants'
44import { DetachedPromise } from '../../lib/detached-promise'
5- import { scheduleImmediate , atLeastOneTask } from '../../lib/scheduler'
5+ import {
6+ scheduleImmediate ,
7+ atLeastOneTask ,
8+ waitAtLeastOneReactRenderTask ,
9+ } from '../../lib/scheduler'
610import { ENCODED_TAGS } from './encoded-tags'
711import {
812 indexOfUint8Array ,
@@ -797,9 +801,13 @@ export async function continueFizzStream(
797801 // Suffix itself might contain close tags at the end, so we need to split it.
798802 const suffixUnclosed = suffix ? suffix . split ( CLOSE_TAG , 1 ) [ 0 ] : null
799803
800- // If we're generating static HTML we need to wait for it to resolve before continuing.
801804 if ( isStaticGeneration ) {
805+ // If we're generating static HTML we need to wait for it to resolve before continuing.
802806 await renderStream . allReady
807+ } else {
808+ // Otherwise, we want to make sure Fizz is done with all microtasky work
809+ // before we start pulling the stream and cause a flush.
810+ await waitAtLeastOneReactRenderTask ( )
803811 }
804812
805813 return chainTransformers ( renderStream , [
You can’t perform that action at this time.
0 commit comments