Skip to content

Commit

Permalink
[Fix] Errors should not "unsuspend" a transition (#22423)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
acdlite authored Sep 27, 2021
1 parent c9d64e5 commit 05726d7
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,8 @@ export function renderDidSuspend(): void {
export function renderDidSuspendDelayIfPossible(): void {
if (
workInProgressRootExitStatus === RootIncomplete ||
workInProgressRootExitStatus === RootSuspended
workInProgressRootExitStatus === RootSuspended ||
workInProgressRootExitStatus === RootErrored
) {
workInProgressRootExitStatus = RootSuspendedWithDelay;
}
Expand All @@ -1469,7 +1470,7 @@ export function renderDidSuspendDelayIfPossible(): void {
}

export function renderDidError() {
if (workInProgressRootExitStatus !== RootCompleted) {
if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
workInProgressRootExitStatus = RootErrored;
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,8 @@ export function renderDidSuspend(): void {
export function renderDidSuspendDelayIfPossible(): void {
if (
workInProgressRootExitStatus === RootIncomplete ||
workInProgressRootExitStatus === RootSuspended
workInProgressRootExitStatus === RootSuspended ||
workInProgressRootExitStatus === RootErrored
) {
workInProgressRootExitStatus = RootSuspendedWithDelay;
}
Expand All @@ -1469,7 +1470,7 @@ export function renderDidSuspendDelayIfPossible(): void {
}

export function renderDidError() {
if (workInProgressRootExitStatus !== RootCompleted) {
if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
workInProgressRootExitStatus = RootErrored;
}
}
Expand Down
Loading

0 comments on commit 05726d7

Please sign in to comment.