Skip to content

Commit f220f7e

Browse files
committed
Hoist up
1 parent 6899f52 commit f220f7e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,18 +3926,8 @@ 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+
const json: string = stringify(value, task.toJSON);
3930+
emitModelChunk(request, task.id, json);
39413931
}
39423932

39433933
function erroredTask(request: Request, task: Task, error: mixed): void {
@@ -3975,8 +3965,11 @@ function retryTask(request: Request, task: Task): void {
39753965
const prevDebugID = debugID;
39763966
task.status = RENDERING;
39773967

3978-
// Stash and restore original size e.g. for when we're retrying strings.
3968+
// We stash the outer parent size so we can restore it when we exit.
39793969
const parentSerializedSize = serializedSize;
3970+
// We don't reset the serialized size counter from reentry because that indicates that we
3971+
// are outlining a model and we actually want to include that size into the parent since
3972+
// it will still block the parent row. It only restores to zero at the top of the stack.
39803973
try {
39813974
// Track the root so we know that we have to emit this object even though it
39823975
// already has an ID. This is needed because we might see this object twice
@@ -4101,9 +4094,11 @@ function tryStreamTask(request: Request, task: Task): void {
41014094
// so that we instead outline the row to get a new debugID if needed.
41024095
debugID = null;
41034096
}
4097+
const parentSerializedSize = serializedSize;
41044098
try {
41054099
emitChunk(request, task, task.model);
41064100
} finally {
4101+
serializedSize = parentSerializedSize;
41074102
if (__DEV__) {
41084103
debugID = prevDebugID;
41094104
}

0 commit comments

Comments
 (0)