@samitouri / QOS-React / commits / 79d9aed7ed

[Fizz] Clean up the replay nodes if we're already rendered past an element (#33581)

Sebastian Markbåge committed Jun 20, 2025 at 03:26 UTC 79d9aed7edb52e89b3ef9ba3d6b480b04180b664
1 file changed +7
packages/react-server/src/ReactFizzServer.js
+7
@@ -3099,6 +3099,9 @@ function replayElement(
3099 if (task.node === currentNode) {
3100 // This same element suspended so we need to pop the replay we just added.
3101 task.replay = replay;
3102 + } else {
3103 + // We finished rendering this node, so now we can consume this slot.
3104 + replayNodes.splice(i, 1);
3105 }
3106 throw x;
3107 }
@@ -4127,6 +4130,8 @@ function renderNode(
4130 const segment = task.blockedSegment;
4131 if (segment === null) {
4132 // Replay
4133 + task = ((task: any): ReplayTask); // Refined
4134 + const previousReplaySet: ReplaySet = task.replay;
4135 try {
4136 return renderNodeDestructive(request, task, node, childIndex);
4137 } catch (thrownValue) {
@@ -4166,6 +4171,7 @@ function renderNode(
4171 task.keyPath = previousKeyPath;
4172 task.treeContext = previousTreeContext;
4173 task.componentStack = previousComponentStack;
4174 + task.replay = previousReplaySet;
4175 if (__DEV__) {
4176 task.debugTask = previousDebugTask;
4177 }
@@ -4199,6 +4205,7 @@ function renderNode(
4205 task.keyPath = previousKeyPath;
4206 task.treeContext = previousTreeContext;
4207 task.componentStack = previousComponentStack;
4208 + task.replay = previousReplaySet;
4209 if (__DEV__) {
4210 task.debugTask = previousDebugTask;
4211 }