Skip to content

Commit 1c9b138

Browse files
authored
Don't serialize chunk ids for Hint and Console rows (#31671)
Hints and Console logs are side-effects and don't belong to any particular value. They're `void`. Therefore they don't need a row ID. In the current parsing scheme it's ok to omit the id. It just becomes `0` which is the initial value which is then unused for these row types. So it looks like: ``` :HP[...] :W[...] 0:{...} ``` We could patch the parsing to encode the tag in the ID so it's more like the ID is the target of the side-effect. ``` H:P[...] W:[...] 0:{...} ``` Or move the tagging to the beginning like it used to be. But this seems simple enough for now.
1 parent de68d2f commit 1c9b138

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/react-server/src/ReactFlightServer.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,8 @@ function patchConsole(consoleInst: typeof console, methodName: string) {
213213
1,
214214
);
215215
request.pendingChunks++;
216-
// We don't currently use this id for anything but we emit it so that we can later
217-
// refer to previous logs in debug info to associate them with a component.
218-
const id = request.nextChunkId++;
219216
const owner: null | ReactComponentInfo = resolveOwner();
220-
emitConsoleChunk(request, id, methodName, owner, stack, arguments);
217+
emitConsoleChunk(request, methodName, owner, stack, arguments);
221218
}
222219
// $FlowFixMe[prop-missing]
223220
return originalMethod.apply(this, arguments);
@@ -3227,8 +3224,7 @@ function emitHintChunk<Code: HintCode>(
32273224
model: HintModel<Code>,
32283225
): void {
32293226
const json: string = stringify(model);
3230-
const id = request.nextChunkId++;
3231-
const row = serializeRowHeader('H' + code, id) + json + '\n';
3227+
const row = ':H' + code + json + '\n';
32323228
const processedChunk = stringToChunk(row);
32333229
request.completedHintChunks.push(processedChunk);
32343230
}
@@ -3764,7 +3760,6 @@ function outlineConsoleValue(
37643760

37653761
function emitConsoleChunk(
37663762
request: Request,
3767-
id: number,
37683763
methodName: string,
37693764
owner: null | ReactComponentInfo,
37703765
stackTrace: ReactStackTrace,
@@ -3828,7 +3823,7 @@ function emitConsoleChunk(
38283823
replacer,
38293824
);
38303825
}
3831-
const row = serializeRowHeader('W', id) + json + '\n';
3826+
const row = ':W' + json + '\n';
38323827
const processedChunk = stringToChunk(row);
38333828
request.completedRegularChunks.push(processedChunk);
38343829
}

0 commit comments

Comments
 (0)