From f03f459da8cd51874c5e5f629c8553d2c23f66a2 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Thu, 21 Nov 2024 16:09:06 -0500 Subject: [PATCH] Mark interrupted renders as prewarm if they were already suspended --- packages/react-reconciler/src/ReactFiberWorkLoop.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 43dd8bd961d5e..9b452020375df 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -1738,7 +1738,18 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes): Fiber { previousRenderStartTime > 0 ) { setCurrentTrackFromLanes(workInProgressRootRenderLanes); - logInterruptedRenderPhase(previousRenderStartTime, renderStartTime); + if ( + workInProgressRootExitStatus === RootSuspended || + workInProgressRootExitStatus === RootSuspendedWithDelay + ) { + // If the root was already suspended when it got interrupted and restarted, + // then this is considered a prewarm and not an interrupted render because + // we couldn't have shown anything anyway so it's not a bad thing that we + // got interrupted. + logSuspendedRenderPhase(previousRenderStartTime, renderStartTime); + } else { + logInterruptedRenderPhase(previousRenderStartTime, renderStartTime); + } finalizeRender(workInProgressRootRenderLanes, renderStartTime); }