Skip to content

Commit 9aeea74

Browse files
committed
Hoist up
1 parent 6899f52 commit 9aeea74

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,18 +3926,9 @@ function emitChunk(
39263926
return;
39273927
}
39283928
// For anything else we need to try to serialize it using JSON.
3929-
// We stash the outer parent size so we can restore it when we exit.
3930-
const parentSerializedSize = serializedSize;
3931-
// We don't reset the serialized size counter from reentry because that indicates that we
3932-
// are outlining a model and we actually want to include that size into the parent since
3933-
// it will still block the parent row. It only restores to zero at the top of the stack.
3934-
try {
3935-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
3936-
const json: string = stringify(value, task.toJSON);
3937-
emitModelChunk(request, task.id, json);
3938-
} finally {
3939-
serializedSize = parentSerializedSize;
3940-
}
3929+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
3930+
const json: string = stringify(value, task.toJSON);
3931+
emitModelChunk(request, task.id, json);
39413932
}
39423933

39433934
function erroredTask(request: Request, task: Task, error: mixed): void {
@@ -3975,8 +3966,11 @@ function retryTask(request: Request, task: Task): void {
39753966
const prevDebugID = debugID;
39763967
task.status = RENDERING;
39773968

3978-
// Stash and restore original size e.g. for when we're retrying strings.
3969+
// We stash the outer parent size so we can restore it when we exit.
39793970
const parentSerializedSize = serializedSize;
3971+
// We don't reset the serialized size counter from reentry because that indicates that we
3972+
// are outlining a model and we actually want to include that size into the parent since
3973+
// it will still block the parent row. It only restores to zero at the top of the stack.
39803974
try {
39813975
// Track the root so we know that we have to emit this object even though it
39823976
// already has an ID. This is needed because we might see this object twice
@@ -4101,9 +4095,11 @@ function tryStreamTask(request: Request, task: Task): void {
41014095
// so that we instead outline the row to get a new debugID if needed.
41024096
debugID = null;
41034097
}
4098+
const parentSerializedSize = serializedSize;
41044099
try {
41054100
emitChunk(request, task, task.model);
41064101
} finally {
4102+
serializedSize = parentSerializedSize;
41074103
if (__DEV__) {
41084104
debugID = prevDebugID;
41094105
}

0 commit comments

Comments
 (0)