diff --git a/fixtures/fizz-ssr-browser-streaming/index.html b/fixtures/fizz-ssr-browser-streaming/index.html new file mode 100644 index 00000000000..b8ce1682e06 --- /dev/null +++ b/fixtures/fizz-ssr-browser-streaming/index.html @@ -0,0 +1,125 @@ + + + + + Fizz Streaming Example + + +

Fizz Example

+
+

+ To install React, follow the instructions on + GitHub. +

+

+ If you can see this, React is not working right. + If you checked out the source from GitHub make sure to run npm run build. +

+
+ + + + + + diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index f06cbc8fb61..fb3c70128d3 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -154,6 +154,7 @@ const COMPLETED = 1; const FLUSHED = 2; const ABORTED = 3; const ERRORED = 4; +const FLUSHING = 5; type Root = null; @@ -178,7 +179,7 @@ export opaque type Request = { destination: null | Destination, +responseState: ResponseState, +progressiveChunkSize: number, - status: 0 | 1 | 2, + status: 0 | 1 | 2 | 5, fatalError: mixed, nextSegmentId: number, allPendingTasks: number, // when it reaches zero, we can close the connection. @@ -1820,6 +1821,11 @@ function flushCompletedQueues( request: Request, destination: Destination, ): void { + if (request.status === FLUSHING) { + return; + } + request.status = FLUSHING; + beginWriting(destination); try { // The structure of this is to go through each queue one by one and write @@ -1907,6 +1913,7 @@ function flushCompletedQueues( } finally { completeWriting(destination); flushBuffered(destination); + request.status = OPEN; if ( request.allPendingTasks === 0 && request.pingedTasks.length === 0 &&