@@ -329,8 +329,8 @@ const RootFatalErrored = 1;
329329const RootErrored = 2 ;
330330const RootSuspended = 3 ;
331331const RootSuspendedWithDelay = 4 ;
332+ const RootSuspendedAtTheShell = 6 ;
332333const RootCompleted = 5 ;
333- const RootDidNotComplete = 6 ;
334334
335335// Describes where we are in the React execution stack
336336let executionContext : ExecutionContext = NoContext ;
@@ -942,15 +942,6 @@ export function performWorkOnRoot(
942942 markRootSuspended ( root , lanes , NoLane , didAttemptEntireTree ) ;
943943 }
944944 break ;
945- } else if ( exitStatus === RootDidNotComplete ) {
946- if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
947- finalizeRender ( lanes , now ( ) ) ;
948- }
949- // The render unwound without completing the tree. This happens in special
950- // cases where need to exit the current render without producing a
951- // consistent tree or committing.
952- const didAttemptEntireTree = ! workInProgressRootDidSkipSuspendedSiblings ;
953- markRootSuspended ( root , lanes , NoLane , didAttemptEntireTree ) ;
954945 } else {
955946 // The render completed.
956947
@@ -998,7 +989,7 @@ export function performWorkOnRoot(
998989 // from the beginning.
999990 // TODO: Refactor the exit algorithm to be less confusing. Maybe
1000991 // more branches + recursion instead of a loop. I think the only
1001- // thing that causes it to be a loop is the RootDidNotComplete
992+ // thing that causes it to be a loop is the RootSuspendedAtTheShell
1002993 // check. If that's true, then we don't need a loop/recursion
1003994 // at all.
1004995 continue ;
@@ -1134,25 +1125,27 @@ function finishConcurrentRender(
11341125 throw new Error ( 'Root did not complete. This is a bug in React.' ) ;
11351126 }
11361127 case RootSuspendedWithDelay : {
1137- if ( includesOnlyTransitions ( lanes ) ) {
1138- // This is a transition, so we should exit without committing a
1139- // placeholder and without scheduling a timeout. Delay indefinitely
1140- // until we receive more data.
1141- if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1142- finalizeRender ( lanes , now ( ) ) ;
1143- }
1144- const didAttemptEntireTree =
1145- ! workInProgressRootDidSkipSuspendedSiblings ;
1146- markRootSuspended (
1147- root ,
1148- lanes ,
1149- workInProgressDeferredLane ,
1150- didAttemptEntireTree ,
1151- ) ;
1152- return ;
1128+ if ( ! includesOnlyTransitions ( lanes ) ) {
1129+ // Commit the placeholder.
1130+ break ;
11531131 }
1154- // Commit the placeholder.
1155- break ;
1132+ }
1133+ // Fallthrough
1134+ case RootSuspendedAtTheShell : {
1135+ // This is a transition, so we should exit without committing a
1136+ // placeholder and without scheduling a timeout. Delay indefinitely
1137+ // until we receive more data.
1138+ if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
1139+ finalizeRender ( lanes , renderEndTime ) ;
1140+ }
1141+ const didAttemptEntireTree = ! workInProgressRootDidSkipSuspendedSiblings ;
1142+ markRootSuspended (
1143+ root ,
1144+ lanes ,
1145+ workInProgressDeferredLane ,
1146+ didAttemptEntireTree ,
1147+ ) ;
1148+ return ;
11561149 }
11571150 case RootErrored : {
11581151 // This render errored. Ignore any recoverable errors because we weren't actually
@@ -2146,7 +2139,7 @@ function renderRootSync(
21462139 // just yield and reset the stack when we re-enter the work loop,
21472140 // like normal.
21482141 resetWorkInProgressStack ( ) ;
2149- exitStatus = RootDidNotComplete ;
2142+ exitStatus = RootSuspendedAtTheShell ;
21502143 break outer;
21512144 }
21522145 case SuspendedOnImmediate :
@@ -2465,7 +2458,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
24652458 // Interrupt the current render so the work loop can switch to the
24662459 // hydration lane.
24672460 resetWorkInProgressStack ( ) ;
2468- workInProgressRootExitStatus = RootDidNotComplete ;
2461+ workInProgressRootExitStatus = RootSuspendedAtTheShell ;
24692462 break outer ;
24702463 }
24712464 default : {
@@ -2973,7 +2966,7 @@ function unwindUnitOfWork(unitOfWork: Fiber, skipSiblings: boolean): void {
29732966 } while ( incompleteWork !== null ) ;
29742967
29752968 // We've unwound all the way to the root.
2976- workInProgressRootExitStatus = RootDidNotComplete ;
2969+ workInProgressRootExitStatus = RootSuspendedAtTheShell ;
29772970 workInProgress = null ;
29782971}
29792972
0 commit comments