Skip to content

Commit

Permalink
Ping suspended level when canceling its timer
Browse files Browse the repository at this point in the history
Make sure the suspended level is marked as pinged so that we return back
to it later, in case the render we're about to start gets aborted.
Generally we only reach this path via a ping, but we shouldn't assume
that will always be the case.
  • Loading branch information
acdlite committed Apr 7, 2020
1 parent 5e28031 commit 86adec4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Expand Up @@ -1168,6 +1168,19 @@ function prepareFreshStack(root, expirationTime) {
cancelTimeout(timeoutHandle);
}

// Check if there's a suspended level at lower priority.
const lastSuspendedTime = root.lastSuspendedTime;
if (lastSuspendedTime !== NoWork && lastSuspendedTime < expirationTime) {
const lastPingedTime = root.lastPingedTime;
// Make sure the suspended level is marked as pinged so that we return back
// to it later, in case the render we're about to start gets aborted.
// Generally we only reach this path via a ping, but we shouldn't assume
// that will always be the case.
if (lastPingedTime === NoWork || lastPingedTime > lastSuspendedTime) {
root.lastPingedTime = lastSuspendedTime;
}
}

if (workInProgress !== null) {
let interruptedWork = workInProgress.return;
while (interruptedWork !== null) {
Expand Down

0 comments on commit 86adec4

Please sign in to comment.