Skip to content

Commit 765c0cb

Browse files
committed
Move debug data first in the stream
This is unfortunate. Ideally you'd expect it to be the least priority but because it blocks the parent elements from resolving it ends up being better to have it first anyway.
1 parent de5c81c commit 765c0cb

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ describe('ReactFlightDOMEdge', () => {
674674
const [stream2, drip] = dripStream(stream);
675675

676676
// Allow some of the content through.
677-
drip(5000);
677+
drip(__DEV__ ? 7500 : 5000);
678678

679679
const result = await ReactServerDOMClient.createFromReadableStream(
680680
stream2,

packages/react-server/src/ReactFlightServer.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,6 +5363,24 @@ function flushCompletedChunks(
53635363
}
53645364
hintChunks.splice(0, i);
53655365

5366+
// Debug meta data comes before the model data because it will often end up blocking the model from
5367+
// completing since the JSX will reference the debug data.
5368+
if (__DEV__) {
5369+
const debugChunks = request.completedDebugChunks;
5370+
i = 0;
5371+
for (; i < debugChunks.length; i++) {
5372+
request.pendingChunks--;
5373+
const chunk = debugChunks[i];
5374+
const keepWriting: boolean = writeChunkAndReturn(destination, chunk);
5375+
if (!keepWriting) {
5376+
request.destination = null;
5377+
i++;
5378+
break;
5379+
}
5380+
}
5381+
debugChunks.splice(0, i);
5382+
}
5383+
53665384
// Next comes model data.
53675385
const regularChunks = request.completedRegularChunks;
53685386
i = 0;
@@ -5394,24 +5412,6 @@ function flushCompletedChunks(
53945412
}
53955413
}
53965414
errorChunks.splice(0, i);
5397-
5398-
// Next comes debug meta data.
5399-
// TODO: Move this first since other chunks are blocked on their debug info. I'm only testing that the client is resilient.
5400-
if (__DEV__) {
5401-
const debugChunks = request.completedDebugChunks;
5402-
i = 0;
5403-
for (; i < debugChunks.length; i++) {
5404-
request.pendingChunks--;
5405-
const chunk = debugChunks[i];
5406-
const keepWriting: boolean = writeChunkAndReturn(destination, chunk);
5407-
if (!keepWriting) {
5408-
request.destination = null;
5409-
i++;
5410-
break;
5411-
}
5412-
}
5413-
debugChunks.splice(0, i);
5414-
}
54155415
} finally {
54165416
request.flushScheduled = false;
54175417
completeWriting(destination);

0 commit comments

Comments
 (0)