Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4438,9 +4438,15 @@ function erroredTask(
const boundaryRow = boundary.row;
if (boundaryRow !== null) {
// Unblock the SuspenseListRow that was blocked by this boundary.
// finishSuspenseListRow → unblockSuspenseListRow → finishedTask reenters
// and decrements allPendingTasks. Pin the counter above zero so those
// nested calls can't trip completeAll before this outer frame's own
// zero check at the end.
request.allPendingTasks++;
if (--boundaryRow.pendingTasks === 0) {
finishSuspenseListRow(request, boundaryRow);
}
request.allPendingTasks--;
}

// Regardless of what happens next, this boundary won't be displayed,
Expand Down Expand Up @@ -4955,20 +4961,21 @@ function finishedTask(
hoistHoistables(boundaryRow.hoistables, boundary.contentState);
}
if (!isEligibleForOutlining(request, boundary)) {
// abortTaskSoft reenters finishedTask for each aborted task, which
// decrements allPendingTasks. Ensure that these reentrant finsihedTask
// calls do not call `completeAll` too early by forcing the task counter
// above zero for their duration.
// abortTaskSoft (below) and finishSuspenseListRow → unblockSuspenseListRow
// → finishedTask (further below) both reenter finishedTask and decrement
// allPendingTasks. Pin the counter above zero for the duration of these
// fan-outs so a nested finishedTask can't observe 0 and call completeAll
// before this outer call reaches its own zero check.
request.allPendingTasks++;
boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request);
boundary.fallbackAbortableTasks.clear();
request.allPendingTasks--;
if (boundaryRow !== null) {
// If we aren't eligible for outlining, we don't have to wait until we flush it.
if (--boundaryRow.pendingTasks === 0) {
finishSuspenseListRow(request, boundaryRow);
}
}
request.allPendingTasks--;
}

if (
Expand All @@ -4994,11 +5001,17 @@ function finishedTask(
boundaryRow.next,
);
}
// finishSuspenseListRow → unblockSuspenseListRow → finishedTask reenters
// and decrements allPendingTasks. Pin the counter above zero so those
// nested calls can't trip completeAll before this outer frame's own
// zero check at the end.
request.allPendingTasks++;
if (--boundaryRow.pendingTasks === 0) {
// This is really unnecessary since we've already postponed the boundaries but
// for pairity with other track+finish paths. We might end up using the hoisting.
finishSuspenseListRow(request, boundaryRow);
}
request.allPendingTasks--;
}
}
} else {
Expand Down
Loading