Skip to content

Commit dc32e7c

Browse files
committed
[Bugfix] Infinite uDV loop in popstate event (#32821)
Found a bug that occurs during a specific combination of very subtle implementation details. It occurs sometimes (not always) when 1) a transition is scheduled during a popstate event, and 2) as a result, a new value is passed to an already-mounted useDeferredValue hook. The fix is relatively straightforward, and I found it almost immediately; it took a bit longer to figure out exactly how the scenario occurred in production and create a test case to simulate it. Rather than couple the test to the implementation details, I've chosen to keep it as high-level as possible so that it doesn't break if the details change. In the future, it might not be trigger the exact set of internal circumstances anymore, but it could be useful for catching similar bugs because it represents a realistic real world situation — namely, switching tabs repeatedly in an app that uses useDeferredValue. DiffTrain build for [6a7650c](6a7650c)
1 parent 28c3ec9 commit dc32e7c

23 files changed

+101
-101
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-efb22d88-20250404
1+
19.2.0-native-fb-6a7650c7-20250405

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<6cfd47f2b21b97b867be835cd77d7d5a>>
10+
* @generated SignedSource<<ea8e5d8de6f333cf51feb72e49979c05>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
407+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<9609c3c47ee272adad57ce5c02b7bc80>>
10+
* @generated SignedSource<<3837e61bda649f4f83575a3fa138f9bc>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
206+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<9609c3c47ee272adad57ce5c02b7bc80>>
10+
* @generated SignedSource<<3837e61bda649f4f83575a3fa138f9bc>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
206+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<be3c156a3439b7c200b4036256b4f46e>>
10+
* @generated SignedSource<<6b3efa4806855987b64a7317b4a298cd>>
1111
*/
1212

1313
/*
@@ -7977,7 +7977,7 @@ __DEV__ &&
79777977
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
79787978
hook
79797979
);
7980-
if (0 === (renderLanes & 42))
7980+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
79817981
return (didReceiveUpdate = !0), (hook.memoizedState = value);
79827982
hook = requestDeferredLane();
79837983
currentlyRenderingFiber.lanes |= hook;
@@ -25769,11 +25769,11 @@ __DEV__ &&
2576925769
};
2577025770
(function () {
2577125771
var isomorphicReactPackageVersion = React.version;
25772-
if ("19.2.0-native-fb-efb22d88-20250404" !== isomorphicReactPackageVersion)
25772+
if ("19.2.0-native-fb-6a7650c7-20250405" !== isomorphicReactPackageVersion)
2577325773
throw Error(
2577425774
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2577525775
(isomorphicReactPackageVersion +
25776-
"\n - react-dom: 19.2.0-native-fb-efb22d88-20250404\nLearn more: https://react.dev/warnings/version-mismatch")
25776+
"\n - react-dom: 19.2.0-native-fb-6a7650c7-20250405\nLearn more: https://react.dev/warnings/version-mismatch")
2577725777
);
2577825778
})();
2577925779
("function" === typeof Map &&
@@ -25810,10 +25810,10 @@ __DEV__ &&
2581025810
!(function () {
2581125811
var internals = {
2581225812
bundleType: 1,
25813-
version: "19.2.0-native-fb-efb22d88-20250404",
25813+
version: "19.2.0-native-fb-6a7650c7-20250405",
2581425814
rendererPackageName: "react-dom",
2581525815
currentDispatcherRef: ReactSharedInternals,
25816-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404"
25816+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405"
2581725817
};
2581825818
internals.overrideHookState = overrideHookState;
2581925819
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -25957,5 +25957,5 @@ __DEV__ &&
2595725957
listenToAllSupportedEvents(container);
2595825958
return new ReactDOMHydrationRoot(initialChildren);
2595925959
};
25960-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
25960+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";
2596125961
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<6ccc9b31afcf0591c941acd8147f5042>>
10+
* @generated SignedSource<<18d0107213b347f0b8d51a335717da4f>>
1111
*/
1212

1313
/*
@@ -5310,7 +5310,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) {
53105310
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
53115311
hook
53125312
);
5313-
if (0 === (renderLanes & 42))
5313+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
53145314
return (didReceiveUpdate = !0), (hook.memoizedState = value);
53155315
hook = requestDeferredLane();
53165316
currentlyRenderingFiber.lanes |= hook;
@@ -16004,14 +16004,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1600416004
};
1600516005
var isomorphicReactPackageVersion$jscomp$inline_1789 = React.version;
1600616006
if (
16007-
"19.2.0-native-fb-efb22d88-20250404" !==
16007+
"19.2.0-native-fb-6a7650c7-20250405" !==
1600816008
isomorphicReactPackageVersion$jscomp$inline_1789
1600916009
)
1601016010
throw Error(
1601116011
formatProdErrorMessage(
1601216012
527,
1601316013
isomorphicReactPackageVersion$jscomp$inline_1789,
16014-
"19.2.0-native-fb-efb22d88-20250404"
16014+
"19.2.0-native-fb-6a7650c7-20250405"
1601516015
)
1601616016
);
1601716017
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16033,10 +16033,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1603316033
};
1603416034
var internals$jscomp$inline_2239 = {
1603516035
bundleType: 0,
16036-
version: "19.2.0-native-fb-efb22d88-20250404",
16036+
version: "19.2.0-native-fb-6a7650c7-20250405",
1603716037
rendererPackageName: "react-dom",
1603816038
currentDispatcherRef: ReactSharedInternals,
16039-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404"
16039+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405"
1604016040
};
1604116041
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1604216042
var hook$jscomp$inline_2240 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16140,4 +16140,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1614016140
listenToAllSupportedEvents(container);
1614116141
return new ReactDOMHydrationRoot(initialChildren);
1614216142
};
16143-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
16143+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b8d634fd9ab90a80e42879d650b44b53>>
10+
* @generated SignedSource<<0a733889ae72898021a337cf766e9ca5>>
1111
*/
1212

1313
/*
@@ -5469,7 +5469,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) {
54695469
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
54705470
hook
54715471
);
5472-
if (0 === (renderLanes & 42))
5472+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
54735473
return (didReceiveUpdate = !0), (hook.memoizedState = value);
54745474
hook = requestDeferredLane();
54755475
currentlyRenderingFiber.lanes |= hook;
@@ -16697,14 +16697,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1669716697
};
1669816698
var isomorphicReactPackageVersion$jscomp$inline_1886 = React.version;
1669916699
if (
16700-
"19.2.0-native-fb-efb22d88-20250404" !==
16700+
"19.2.0-native-fb-6a7650c7-20250405" !==
1670116701
isomorphicReactPackageVersion$jscomp$inline_1886
1670216702
)
1670316703
throw Error(
1670416704
formatProdErrorMessage(
1670516705
527,
1670616706
isomorphicReactPackageVersion$jscomp$inline_1886,
16707-
"19.2.0-native-fb-efb22d88-20250404"
16707+
"19.2.0-native-fb-6a7650c7-20250405"
1670816708
)
1670916709
);
1671016710
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16726,10 +16726,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1672616726
};
1672716727
var internals$jscomp$inline_1893 = {
1672816728
bundleType: 0,
16729-
version: "19.2.0-native-fb-efb22d88-20250404",
16729+
version: "19.2.0-native-fb-6a7650c7-20250405",
1673016730
rendererPackageName: "react-dom",
1673116731
currentDispatcherRef: ReactSharedInternals,
16732-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404",
16732+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405",
1673316733
getLaneLabelMap: function () {
1673416734
for (
1673516735
var map = new Map(), lane = 1, index$294 = 0;
@@ -16848,4 +16848,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1684816848
listenToAllSupportedEvents(container);
1684916849
return new ReactDOMHydrationRoot(initialChildren);
1685016850
};
16851-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
16851+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a4117b8695e0bb8c6e3f4a92b08a43e4>>
10+
* @generated SignedSource<<3c46d1d9ec7a5dc3375998a8ed253bf1>>
1111
*/
1212

1313
/*
@@ -7985,7 +7985,7 @@ __DEV__ &&
79857985
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
79867986
hook
79877987
);
7988-
if (0 === (renderLanes & 42))
7988+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
79897989
return (didReceiveUpdate = !0), (hook.memoizedState = value);
79907990
hook = requestDeferredLane();
79917991
currentlyRenderingFiber.lanes |= hook;
@@ -25830,11 +25830,11 @@ __DEV__ &&
2583025830
};
2583125831
(function () {
2583225832
var isomorphicReactPackageVersion = React.version;
25833-
if ("19.2.0-native-fb-efb22d88-20250404" !== isomorphicReactPackageVersion)
25833+
if ("19.2.0-native-fb-6a7650c7-20250405" !== isomorphicReactPackageVersion)
2583425834
throw Error(
2583525835
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2583625836
(isomorphicReactPackageVersion +
25837-
"\n - react-dom: 19.2.0-native-fb-efb22d88-20250404\nLearn more: https://react.dev/warnings/version-mismatch")
25837+
"\n - react-dom: 19.2.0-native-fb-6a7650c7-20250405\nLearn more: https://react.dev/warnings/version-mismatch")
2583825838
);
2583925839
})();
2584025840
("function" === typeof Map &&
@@ -25871,10 +25871,10 @@ __DEV__ &&
2587125871
!(function () {
2587225872
var internals = {
2587325873
bundleType: 1,
25874-
version: "19.2.0-native-fb-efb22d88-20250404",
25874+
version: "19.2.0-native-fb-6a7650c7-20250405",
2587525875
rendererPackageName: "react-dom",
2587625876
currentDispatcherRef: ReactSharedInternals,
25877-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404"
25877+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405"
2587825878
};
2587925879
internals.overrideHookState = overrideHookState;
2588025880
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26334,7 +26334,7 @@ __DEV__ &&
2633426334
exports.useFormStatus = function () {
2633526335
return resolveDispatcher().useHostTransitionStatus();
2633626336
};
26337-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
26337+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";
2633826338
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2633926339
"function" ===
2634026340
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<3d71bd2aa496d54cc82b8e1eaba30156>>
10+
* @generated SignedSource<<d73473e1ae2573ba802eafcafab105e9>>
1111
*/
1212

1313
/*
@@ -5310,7 +5310,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) {
53105310
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
53115311
hook
53125312
);
5313-
if (0 === (renderLanes & 42))
5313+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
53145314
return (didReceiveUpdate = !0), (hook.memoizedState = value);
53155315
hook = requestDeferredLane();
53165316
currentlyRenderingFiber.lanes |= hook;
@@ -16015,14 +16015,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1601516015
};
1601616016
var isomorphicReactPackageVersion$jscomp$inline_1790 = React.version;
1601716017
if (
16018-
"19.2.0-native-fb-efb22d88-20250404" !==
16018+
"19.2.0-native-fb-6a7650c7-20250405" !==
1601916019
isomorphicReactPackageVersion$jscomp$inline_1790
1602016020
)
1602116021
throw Error(
1602216022
formatProdErrorMessage(
1602316023
527,
1602416024
isomorphicReactPackageVersion$jscomp$inline_1790,
16025-
"19.2.0-native-fb-efb22d88-20250404"
16025+
"19.2.0-native-fb-6a7650c7-20250405"
1602616026
)
1602716027
);
1602816028
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16044,10 +16044,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1604416044
};
1604516045
var internals$jscomp$inline_2242 = {
1604616046
bundleType: 0,
16047-
version: "19.2.0-native-fb-efb22d88-20250404",
16047+
version: "19.2.0-native-fb-6a7650c7-20250405",
1604816048
rendererPackageName: "react-dom",
1604916049
currentDispatcherRef: ReactSharedInternals,
16050-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404"
16050+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405"
1605116051
};
1605216052
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1605316053
var hook$jscomp$inline_2243 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16305,4 +16305,4 @@ exports.useFormState = function (action, initialState, permalink) {
1630516305
exports.useFormStatus = function () {
1630616306
return ReactSharedInternals.H.useHostTransitionStatus();
1630716307
};
16308-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
16308+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<cfc6357d7ba2d65960ac4500c11de855>>
10+
* @generated SignedSource<<c1c7f1f6152a02405a57ad3e92157e95>>
1111
*/
1212

1313
/*
@@ -5473,7 +5473,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) {
54735473
objectIs(hook, prevValue) || (didReceiveUpdate = !0),
54745474
hook
54755475
);
5476-
if (0 === (renderLanes & 42))
5476+
if (0 === (renderLanes & 42) || 0 !== (renderLanes & 1073741824))
54775477
return (didReceiveUpdate = !0), (hook.memoizedState = value);
54785478
hook = requestDeferredLane();
54795479
currentlyRenderingFiber.lanes |= hook;
@@ -16712,14 +16712,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1671216712
};
1671316713
var isomorphicReactPackageVersion$jscomp$inline_1887 = React.version;
1671416714
if (
16715-
"19.2.0-native-fb-efb22d88-20250404" !==
16715+
"19.2.0-native-fb-6a7650c7-20250405" !==
1671616716
isomorphicReactPackageVersion$jscomp$inline_1887
1671716717
)
1671816718
throw Error(
1671916719
formatProdErrorMessage(
1672016720
527,
1672116721
isomorphicReactPackageVersion$jscomp$inline_1887,
16722-
"19.2.0-native-fb-efb22d88-20250404"
16722+
"19.2.0-native-fb-6a7650c7-20250405"
1672316723
)
1672416724
);
1672516725
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16741,10 +16741,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1674116741
};
1674216742
var internals$jscomp$inline_1894 = {
1674316743
bundleType: 0,
16744-
version: "19.2.0-native-fb-efb22d88-20250404",
16744+
version: "19.2.0-native-fb-6a7650c7-20250405",
1674516745
rendererPackageName: "react-dom",
1674616746
currentDispatcherRef: ReactSharedInternals,
16747-
reconcilerVersion: "19.2.0-native-fb-efb22d88-20250404",
16747+
reconcilerVersion: "19.2.0-native-fb-6a7650c7-20250405",
1674816748
getLaneLabelMap: function () {
1674916749
for (
1675016750
var map = new Map(), lane = 1, index$294 = 0;
@@ -17017,7 +17017,7 @@ exports.useFormState = function (action, initialState, permalink) {
1701717017
exports.useFormStatus = function () {
1701817018
return ReactSharedInternals.H.useHostTransitionStatus();
1701917019
};
17020-
exports.version = "19.2.0-native-fb-efb22d88-20250404";
17020+
exports.version = "19.2.0-native-fb-6a7650c7-20250405";
1702117021
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1702217022
"function" ===
1702317023
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)