Skip to content

Commit 2505bf9

Browse files
authored
[Fizz] track postpones when aborting boundaries with a postpone (#30751)
When aborting with a postpone value boundaries are put into client rendered mode even during prerenders. This doesn't follow the postpoen semantics of the rest of fizz where during a prerender a postpone is tracked and it will leave holes in tracked postpone state that can be resumed. This change updates this behavior to match the postpones semantics between aborts and imperative postpones.
1 parent 5997072 commit 2505bf9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7727,7 +7727,6 @@ describe('ReactDOMFizzServer', () => {
77277727

77287728
const prerendered = await pendingPrerender;
77297729

7730-
expect(prerendered.postponed).toBe(null);
77317730
expect(errors).toEqual([]);
77327731
expect(postpones).toEqual(['manufactured', 'manufactured']);
77337732

packages/react-server/src/ReactFizzServer.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3857,7 +3857,6 @@ function abortTask(task: Task, request: Request, error: mixed): void {
38573857
} else {
38583858
boundary.pendingTasks--;
38593859
if (boundary.status !== CLIENT_RENDERED) {
3860-
boundary.status = CLIENT_RENDERED;
38613860
// We construct an errorInfo from the boundary's componentStack so the error in dev will indicate which
38623861
// boundary the message is referring to
38633862
const errorInfo = getThrownInfo(task.componentStack);
@@ -3870,11 +3869,24 @@ function abortTask(task: Task, request: Request, error: mixed): void {
38703869
) {
38713870
const postponeInstance: Postpone = (error: any);
38723871
logPostpone(request, postponeInstance.message, errorInfo, null);
3872+
if (request.trackedPostpones !== null && segment !== null) {
3873+
trackPostpone(request, request.trackedPostpones, task, segment);
3874+
finishedTask(request, task.blockedBoundary, segment);
3875+
3876+
// If this boundary was still pending then we haven't already cancelled its fallbacks.
3877+
// We'll need to abort the fallbacks, which will also error that parent boundary.
3878+
boundary.fallbackAbortableTasks.forEach(fallbackTask =>
3879+
abortTask(fallbackTask, request, error),
3880+
);
3881+
boundary.fallbackAbortableTasks.clear();
3882+
return;
3883+
}
38733884
// TODO: Figure out a better signal than a magic digest value.
38743885
errorDigest = 'POSTPONE';
38753886
} else {
38763887
errorDigest = logRecoverableError(request, error, errorInfo, null);
38773888
}
3889+
boundary.status = CLIENT_RENDERED;
38783890
encodeErrorForBoundary(boundary, errorDigest, error, errorInfo, true);
38793891

38803892
untrackBoundary(request, boundary);

0 commit comments

Comments
 (0)