Skip to content

Commit 8645118

Browse files
committed
[Fix] Errors should not "unsuspend" a transition
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 1c73cee commit 8645118

File tree

3 files changed

+407
-4
lines changed

3 files changed

+407
-4
lines changed

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
}

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)