Skip to content

Commit a65bb22

Browse files
committed
Don't add null placeholder
Instead we wait to add a debug info entry until it resolves. This will always be in order since they depend on each other.
1 parent 9ec0211 commit a65bb22

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -832,27 +832,35 @@ function initializeDebugChunk(
832832
const debugInfo = chunk._debugInfo || (chunk._debugInfo = []);
833833
try {
834834
if (debugChunk.status === RESOLVED_MODEL) {
835+
// Find the index of this debug info by walking the linked list.
836+
let idx = debugInfo.length;
837+
let c = debugChunk._debugChunk;
838+
while (c !== null) {
839+
if (c.status !== INITIALIZED) {
840+
idx++;
841+
}
842+
c = c._debugChunk;
843+
}
835844
// Initializing the model for the first time.
836845
initializeModelChunk(debugChunk);
837846
const initializedChunk = ((debugChunk: any): SomeChunk<any>);
838847
switch (initializedChunk.status) {
839848
case INITIALIZED: {
840-
debugInfo.push(
841-
initializeDebugInfo(response, initializedChunk.value),
849+
debugInfo[idx] = initializeDebugInfo(
850+
response,
851+
initializedChunk.value,
842852
);
843853
break;
844854
}
845855
case BLOCKED:
846856
case PENDING: {
847-
debugInfo.push(
848-
waitForReference(
849-
initializedChunk,
850-
debugInfo,
851-
'' + debugInfo.length, // eslint-disable-line react-internal/safe-string-coercion
852-
response,
853-
initializeDebugInfo,
854-
[''], // path
855-
),
857+
waitForReference(
858+
initializedChunk,
859+
debugInfo,
860+
'' + idx,
861+
response,
862+
initializeDebugInfo,
863+
[''], // path
856864
);
857865
break;
858866
}

0 commit comments

Comments
 (0)