Skip to content

Commit 013d7fe

Browse files
committed
[WIP] Shot-in-the-dark bugfix guess
Got a non-reproducible bug report internally. Based on the info in the bug report, I think it might be related to this code here. The original code is definitely wrong but I don't know if it's the same bug that's being reported. Pushing this so we can try it and see. Will try to write a test and land the fix regardless.
1 parent 4225133 commit 013d7fe

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,18 +740,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
740740

741741
// Flush any pending passive effects before deciding which lanes to work on,
742742
// in case they schedule additional work.
743-
const originalCallbackNode = root.callbackNode;
743+
const originalCallbackPriority = root.callbackPriority;
744744
const didFlushPassiveEffects = flushPassiveEffects();
745745
if (didFlushPassiveEffects) {
746746
// Something in the passive effect phase may have canceled the current task.
747747
// Check if the task node for this root was changed.
748-
if (root.callbackNode !== originalCallbackNode) {
748+
if (root.callbackPriority !== originalCallbackPriority) {
749749
// The current task was canceled. Exit. We don't need to call
750750
// `ensureRootIsScheduled` because the check above implies either that
751751
// there's a new task, or that there's no remaining work on this root.
752752
return null;
753-
} else {
754-
// Current task was not canceled. Continue.
755753
}
756754
}
757755

@@ -822,7 +820,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
822820
}
823821

824822
ensureRootIsScheduled(root, now());
825-
if (root.callbackNode === originalCallbackNode) {
823+
if (root.callbackPriority === originalCallbackPriority) {
826824
// The task node scheduled for this root is the same one that's
827825
// currently executed. Need to return a continuation.
828826
return performConcurrentWorkOnRoot.bind(null, root);

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,18 +740,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
740740

741741
// Flush any pending passive effects before deciding which lanes to work on,
742742
// in case they schedule additional work.
743-
const originalCallbackNode = root.callbackNode;
743+
const originalCallbackPriority = root.callbackPriority;
744744
const didFlushPassiveEffects = flushPassiveEffects();
745745
if (didFlushPassiveEffects) {
746746
// Something in the passive effect phase may have canceled the current task.
747747
// Check if the task node for this root was changed.
748-
if (root.callbackNode !== originalCallbackNode) {
748+
if (root.callbackPriority !== originalCallbackPriority) {
749749
// The current task was canceled. Exit. We don't need to call
750750
// `ensureRootIsScheduled` because the check above implies either that
751751
// there's a new task, or that there's no remaining work on this root.
752752
return null;
753-
} else {
754-
// Current task was not canceled. Continue.
755753
}
756754
}
757755

@@ -822,7 +820,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
822820
}
823821

824822
ensureRootIsScheduled(root, now());
825-
if (root.callbackNode === originalCallbackNode) {
823+
if (root.callbackPriority === originalCallbackPriority) {
826824
// The task node scheduled for this root is the same one that's
827825
// currently executed. Need to return a continuation.
828826
return performConcurrentWorkOnRoot.bind(null, root);

0 commit comments

Comments
 (0)