Skip to content

Commit

Permalink
Fix continuation bug (#31434)
Browse files Browse the repository at this point in the history
## Overview

In `scheduleTaskForRootDuringMicrotask` we clear `root.callbackNode` if
the work loop is [suspended waiting on
data](https://github.com/facebook/react/blob/ac3ca097aeecae8fe3ec7f9b286307a923676518/packages/react-reconciler/src/ReactFiberRootScheduler.js#L338).

But we don't null check `root.callbackNode` before returning a
continuation in `performWorkOnRootViaSchedulerTask` where
`scheduleTaskForRootDuringMicrotask` is synchronously called, causing an
infinite loop when the only thing in the queue is something suspended
waiting on data.

This essentially restores the behavior from here:
https://github.com/facebook/react/pull/26328/files#diff-72ff2175ae3569037f0b16802a41b0cda2b2d66bb97f2bda78ed8445ed487b58L1168

Found by investigating the failures for
#31417

## TODO
- add a test

---------

Co-authored-by: Joe Savona <joesavona@fb.com>

DiffTrain build for [b836de6](b836de6)
  • Loading branch information
rickhanlonii committed Nov 11, 2024
1 parent 1decb40 commit a6bc139
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 101 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-989af12f-20241108
19.0.0-native-fb-b836de61-20241111
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d3072dc54c06b9fce9de2382ae8e659b>>
* @generated SignedSource<<20bf25501f1b0c2f2b4993b1de55a3f9>>
*/

"use strict";
Expand Down Expand Up @@ -420,5 +420,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<dd9c52551f32d06520da8c1e032485fc>>
* @generated SignedSource<<04c0955e73811fad1abcfe89af632cc4>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<dd9c52551f32d06520da8c1e032485fc>>
* @generated SignedSource<<04c0955e73811fad1abcfe89af632cc4>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<261a27b186e17869cdcd7a66d14f2fcf>>
* @generated SignedSource<<03bb96c4e73bfacb9b84b501834b5955>>
*/

/*
Expand Down Expand Up @@ -16713,7 +16713,8 @@ __DEV__ &&
didTimeout
);
scheduleTaskForRootDuringMicrotask(root, now$1());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode &&
root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -25351,11 +25352,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-989af12f-20241108" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-b836de61-20241111" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.0.0-native-fb-989af12f-20241108\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.0.0-native-fb-b836de61-20241111\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -25392,11 +25393,11 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108"
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -25540,5 +25541,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<97be0d694c4e259ac6b44ee1dc9e92f0>>
* @generated SignedSource<<fe7cce54c6c1a69cbd41b014f6eb148d>>
*/

/*
Expand Down Expand Up @@ -12038,7 +12038,7 @@ function performWorkOnRootViaSchedulerTask(root, didTimeout) {
if (0 === workInProgressRootRenderLanes$jscomp$0) return null;
performWorkOnRoot(root, workInProgressRootRenderLanes$jscomp$0, didTimeout);
scheduleTaskForRootDuringMicrotask(root, now());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode && root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -15638,14 +15638,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1698 = React.version;
if (
"19.0.0-native-fb-989af12f-20241108" !==
"19.0.0-native-fb-b836de61-20241111" !==
isomorphicReactPackageVersion$jscomp$inline_1698
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1698,
"19.0.0-native-fb-989af12f-20241108"
"19.0.0-native-fb-b836de61-20241111"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -15667,11 +15667,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2156 = {
bundleType: 0,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108"
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2157 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15775,4 +15775,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a877052bae48c8344bea141cecdfcd5c>>
* @generated SignedSource<<a608054d5a0e409d1ca9e9eba0573bcc>>
*/

/*
Expand Down Expand Up @@ -12682,7 +12682,7 @@ function performWorkOnRootViaSchedulerTask(root, didTimeout) {
if (0 === workInProgressRootRenderLanes$jscomp$0) return null;
performWorkOnRoot(root, workInProgressRootRenderLanes$jscomp$0, didTimeout);
scheduleTaskForRootDuringMicrotask(root, now$1());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode && root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -16292,14 +16292,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1788 = React.version;
if (
"19.0.0-native-fb-989af12f-20241108" !==
"19.0.0-native-fb-b836de61-20241111" !==
isomorphicReactPackageVersion$jscomp$inline_1788
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1788,
"19.0.0-native-fb-989af12f-20241108"
"19.0.0-native-fb-b836de61-20241111"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16321,11 +16321,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1795 = {
bundleType: 0,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108",
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$291 = 0;
Expand Down Expand Up @@ -16444,4 +16444,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<30d439ced802b7158cc5be4e5f13b01e>>
* @generated SignedSource<<0c1713e952feb53c4dd0d0612ac09a13>>
*/

/*
Expand Down Expand Up @@ -16725,7 +16725,8 @@ __DEV__ &&
didTimeout
);
scheduleTaskForRootDuringMicrotask(root, now$1());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode &&
root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -25412,11 +25413,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-989af12f-20241108" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-b836de61-20241111" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.0.0-native-fb-989af12f-20241108\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.0.0-native-fb-b836de61-20241111\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -25453,11 +25454,11 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108"
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -25917,7 +25918,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<5a096c3eed520ec28b8b68efbfa07b0c>>
* @generated SignedSource<<e9a0c9ceb47ef2c6d946337324cf0e6b>>
*/

/*
Expand Down Expand Up @@ -12038,7 +12038,7 @@ function performWorkOnRootViaSchedulerTask(root, didTimeout) {
if (0 === workInProgressRootRenderLanes$jscomp$0) return null;
performWorkOnRoot(root, workInProgressRootRenderLanes$jscomp$0, didTimeout);
scheduleTaskForRootDuringMicrotask(root, now());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode && root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -15649,14 +15649,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1699 = React.version;
if (
"19.0.0-native-fb-989af12f-20241108" !==
"19.0.0-native-fb-b836de61-20241111" !==
isomorphicReactPackageVersion$jscomp$inline_1699
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1699,
"19.0.0-native-fb-989af12f-20241108"
"19.0.0-native-fb-b836de61-20241111"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -15678,11 +15678,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2159 = {
bundleType: 0,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108"
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2160 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15940,4 +15940,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e6967cf8448948037f587c841a6a1b0c>>
* @generated SignedSource<<cffc954821808c368ed8397eceb89b51>>
*/

/*
Expand Down Expand Up @@ -12686,7 +12686,7 @@ function performWorkOnRootViaSchedulerTask(root, didTimeout) {
if (0 === workInProgressRootRenderLanes$jscomp$0) return null;
performWorkOnRoot(root, workInProgressRootRenderLanes$jscomp$0, didTimeout);
scheduleTaskForRootDuringMicrotask(root, now$1());
return root.callbackNode === originalCallbackNode
return null != root.callbackNode && root.callbackNode === originalCallbackNode
? performWorkOnRootViaSchedulerTask.bind(null, root)
: null;
}
Expand Down Expand Up @@ -16307,14 +16307,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1789 = React.version;
if (
"19.0.0-native-fb-989af12f-20241108" !==
"19.0.0-native-fb-b836de61-20241111" !==
isomorphicReactPackageVersion$jscomp$inline_1789
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1789,
"19.0.0-native-fb-989af12f-20241108"
"19.0.0-native-fb-b836de61-20241111"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16336,11 +16336,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1796 = {
bundleType: 0,
version: "19.0.0-native-fb-989af12f-20241108",
version: "19.0.0-native-fb-b836de61-20241111",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-989af12f-20241108",
reconcilerVersion: "19.0.0-native-fb-b836de61-20241111",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$291 = 0;
Expand Down Expand Up @@ -16613,7 +16613,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-989af12f-20241108";
exports.version = "19.0.0-native-fb-b836de61-20241111";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit a6bc139

Please sign in to comment.