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

This commit is contained in:
Sebastian Markbåge 2025-06-20 03:26:26 -04:00 committed by GitHub
parent c8822e926b
commit 79d9aed7ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3099,6 +3099,9 @@ function replayElement(
if (task.node === currentNode) { if (task.node === currentNode) {
// This same element suspended so we need to pop the replay we just added. // This same element suspended so we need to pop the replay we just added.
task.replay = replay; task.replay = replay;
} else {
// We finished rendering this node, so now we can consume this slot.
replayNodes.splice(i, 1);
} }
throw x; throw x;
} }
@ -4127,6 +4130,8 @@ function renderNode(
const segment = task.blockedSegment; const segment = task.blockedSegment;
if (segment === null) { if (segment === null) {
// Replay // Replay
task = ((task: any): ReplayTask); // Refined
const previousReplaySet: ReplaySet = task.replay;
try { try {
return renderNodeDestructive(request, task, node, childIndex); return renderNodeDestructive(request, task, node, childIndex);
} catch (thrownValue) { } catch (thrownValue) {
@ -4166,6 +4171,7 @@ function renderNode(
task.keyPath = previousKeyPath; task.keyPath = previousKeyPath;
task.treeContext = previousTreeContext; task.treeContext = previousTreeContext;
task.componentStack = previousComponentStack; task.componentStack = previousComponentStack;
task.replay = previousReplaySet;
if (__DEV__) { if (__DEV__) {
task.debugTask = previousDebugTask; task.debugTask = previousDebugTask;
} }
@ -4199,6 +4205,7 @@ function renderNode(
task.keyPath = previousKeyPath; task.keyPath = previousKeyPath;
task.treeContext = previousTreeContext; task.treeContext = previousTreeContext;
task.componentStack = previousComponentStack; task.componentStack = previousComponentStack;
task.replay = previousReplaySet;
if (__DEV__) { if (__DEV__) {
task.debugTask = previousDebugTask; task.debugTask = previousDebugTask;
} }