Skip to content

Commit 05726d7

Browse files
authored
[Fix] Errors should not "unsuspend" a transition (#22423)
If an error is thrown during a transition where we would have otherwise suspended without showing a fallback (i.e. during a refresh), we should still suspend. The current behavior is that the error will force the fallback to appear, even if it's completely unrelated to the component that errored, which breaks the contract of `startTransition`.
1 parent c9d64e5 commit 05726d7

File tree

3 files changed

+407
-4
lines changed

3 files changed

+407
-4
lines changed

Diff for: packages/react-reconciler/src/ReactFiberWorkLoop.new.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,8 @@ export function renderDidSuspend(): void {
14451445
export function renderDidSuspendDelayIfPossible(): void {
14461446
if (
14471447
workInProgressRootExitStatus === RootIncomplete ||
1448-
workInProgressRootExitStatus === RootSuspended
1448+
workInProgressRootExitStatus === RootSuspended ||
1449+
workInProgressRootExitStatus === RootErrored
14491450
) {
14501451
workInProgressRootExitStatus = RootSuspendedWithDelay;
14511452
}
@@ -1469,7 +1470,7 @@ export function renderDidSuspendDelayIfPossible(): void {
14691470
}
14701471

14711472
export function renderDidError() {
1472-
if (workInProgressRootExitStatus !== RootCompleted) {
1473+
if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
14731474
workInProgressRootExitStatus = RootErrored;
14741475
}
14751476
}

Diff for: packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,8 @@ export function renderDidSuspend(): void {
14451445
export function renderDidSuspendDelayIfPossible(): void {
14461446
if (
14471447
workInProgressRootExitStatus === RootIncomplete ||
1448-
workInProgressRootExitStatus === RootSuspended
1448+
workInProgressRootExitStatus === RootSuspended ||
1449+
workInProgressRootExitStatus === RootErrored
14491450
) {
14501451
workInProgressRootExitStatus = RootSuspendedWithDelay;
14511452
}
@@ -1469,7 +1470,7 @@ export function renderDidSuspendDelayIfPossible(): void {
14691470
}
14701471

14711472
export function renderDidError() {
1472-
if (workInProgressRootExitStatus !== RootCompleted) {
1473+
if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
14731474
workInProgressRootExitStatus = RootErrored;
14741475
}
14751476
}

0 commit comments

Comments
 (0)