Skip to content

Commit 86adec4

Browse files
committedApr 7, 2020
Ping suspended level when canceling its timer
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.
1 parent 5e28031 commit 86adec4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎packages/react-reconciler/src/ReactFiberWorkLoop.js

+13
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,19 @@ function prepareFreshStack(root, expirationTime) {
11681168
cancelTimeout(timeoutHandle);
11691169
}
11701170

1171+
// Check if there's a suspended level at lower priority.
1172+
const lastSuspendedTime = root.lastSuspendedTime;
1173+
if (lastSuspendedTime !== NoWork && lastSuspendedTime < expirationTime) {
1174+
const lastPingedTime = root.lastPingedTime;
1175+
// Make sure the suspended level is marked as pinged so that we return back
1176+
// to it later, in case the render we're about to start gets aborted.
1177+
// Generally we only reach this path via a ping, but we shouldn't assume
1178+
// that will always be the case.
1179+
if (lastPingedTime === NoWork || lastPingedTime > lastSuspendedTime) {
1180+
root.lastPingedTime = lastSuspendedTime;
1181+
}
1182+
}
1183+
11711184
if (workInProgress !== null) {
11721185
let interruptedWork = workInProgress.return;
11731186
while (interruptedWork !== null) {

0 commit comments

Comments
 (0)