Skip to content

Commit 8df739c

Browse files
committed
Bugfix: Remove extra render pass when reverting to client render (#26445)
(This was reviewed and approved as part of #26380; I'm extracting it into its own PR so that it can bisected later if it causes an issue.) I noticed while working on a PR that when an error happens during hydration, and we revert to client rendering, React actually does _two_ additional render passes instead of just one. We didn't notice it earlier because none of our tests happened to assert on how many renders it took to recover, only on the final output. It's possible this extra render pass had other consequences that I'm not aware of, like messing with some assumption in the recoverable errors logic. This adds a test to demonstrate the issue. (One problem is that we don't have much test coverage of this scenario in the first place, which likely would have caught this earlier.) DiffTrain build for commit 77ba161.
1 parent 7d0009a commit 8df739c

File tree

12 files changed

+27
-27
lines changed

12 files changed

+27
-27
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15116,7 +15116,7 @@ function completeWork(current, workInProgress, renderLanes) {
1511615116
);
1511715117

1511815118
if (!fallthroughToNormalSuspensePath) {
15119-
if (workInProgress.flags & ShouldCapture) {
15119+
if (workInProgress.flags & ForceClientRender) {
1512015120
// Special case. There were remaining unhydrated nodes. We treat
1512115121
// this as a mismatch. Revert to client rendering.
1512215122
return workInProgress;
@@ -23588,7 +23588,7 @@ function createFiberRoot(
2358823588
return root;
2358923589
}
2359023590

23591-
var ReactVersion = "18.3.0-next-520f7f3ed-20230320";
23591+
var ReactVersion = "18.3.0-next-77ba1618a-20230320";
2359223592

2359323593
// Might add PROFILE later.
2359423594

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4507,7 +4507,7 @@ function completeWork(current, workInProgress, renderLanes) {
45074507
null !== hydrationErrors &&
45084508
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
45094509
(index = !0);
4510-
if (!index) return workInProgress.flags & 65536 ? workInProgress : null;
4510+
if (!index) return workInProgress.flags & 256 ? workInProgress : null;
45114511
}
45124512
if (0 !== (workInProgress.flags & 128))
45134513
return (workInProgress.lanes = renderLanes), workInProgress;
@@ -8561,7 +8561,7 @@ var devToolsConfig$jscomp$inline_1013 = {
85618561
throw Error("TestRenderer does not support findFiberByHostInstance()");
85628562
},
85638563
bundleType: 0,
8564-
version: "18.3.0-next-520f7f3ed-20230320",
8564+
version: "18.3.0-next-77ba1618a-20230320",
85658565
rendererPackageName: "react-test-renderer"
85668566
};
85678567
var internals$jscomp$inline_1201 = {
@@ -8592,7 +8592,7 @@ var internals$jscomp$inline_1201 = {
85928592
scheduleRoot: null,
85938593
setRefreshHandler: null,
85948594
getCurrentFiber: null,
8595-
reconcilerVersion: "18.3.0-next-520f7f3ed-20230320"
8595+
reconcilerVersion: "18.3.0-next-77ba1618a-20230320"
85968596
};
85978597
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
85988598
var hook$jscomp$inline_1202 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4650,7 +4650,7 @@ function completeWork(current, workInProgress, renderLanes) {
46504650
null !== hydrationErrors &&
46514651
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
46524652
(index = !0);
4653-
if (!index) return workInProgress.flags & 65536 ? workInProgress : null;
4653+
if (!index) return workInProgress.flags & 256 ? workInProgress : null;
46544654
}
46554655
if (0 !== (workInProgress.flags & 128))
46564656
return (
@@ -8988,7 +8988,7 @@ var devToolsConfig$jscomp$inline_1054 = {
89888988
throw Error("TestRenderer does not support findFiberByHostInstance()");
89898989
},
89908990
bundleType: 0,
8991-
version: "18.3.0-next-520f7f3ed-20230320",
8991+
version: "18.3.0-next-77ba1618a-20230320",
89928992
rendererPackageName: "react-test-renderer"
89938993
};
89948994
var internals$jscomp$inline_1240 = {
@@ -9019,7 +9019,7 @@ var internals$jscomp$inline_1240 = {
90199019
scheduleRoot: null,
90209020
setRefreshHandler: null,
90219021
getCurrentFiber: null,
9022-
reconcilerVersion: "18.3.0-next-520f7f3ed-20230320"
9022+
reconcilerVersion: "18.3.0-next-77ba1618a-20230320"
90239023
};
90249024
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
90259025
var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-next-520f7f3ed-20230320";
30+
var ReactVersion = "18.3.0-next-77ba1618a-20230320";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
639639
);
640640
};
641641
exports.useTransition = useTransition;
642-
exports.version = "18.3.0-next-520f7f3ed-20230320";
642+
exports.version = "18.3.0-next-77ba1618a-20230320";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ exports.useSyncExternalStore = function (
642642
);
643643
};
644644
exports.useTransition = useTransition;
645-
exports.version = "18.3.0-next-520f7f3ed-20230320";
645+
exports.version = "18.3.0-next-77ba1618a-20230320";
646646

647647
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
648648
if (

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18687,7 +18687,7 @@ function completeWork(current, workInProgress, renderLanes) {
1868718687
);
1868818688

1868918689
if (!fallthroughToNormalSuspensePath) {
18690-
if (workInProgress.flags & ShouldCapture) {
18690+
if (workInProgress.flags & ForceClientRender) {
1869118691
// Special case. There were remaining unhydrated nodes. We treat
1869218692
// this as a mismatch. Revert to client rendering.
1869318693
return workInProgress;
@@ -26342,7 +26342,7 @@ function createFiberRoot(
2634226342
return root;
2634326343
}
2634426344

26345-
var ReactVersion = "18.3.0-next-520f7f3ed-20230320";
26345+
var ReactVersion = "18.3.0-next-77ba1618a-20230320";
2634626346

2634726347
function createPortal$1(
2634826348
children,

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5837,7 +5837,7 @@ function completeWork(current, workInProgress, renderLanes) {
58375837
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
58385838
(currentInstance = !0);
58395839
if (!currentInstance)
5840-
return workInProgress.flags & 65536 ? workInProgress : null;
5840+
return workInProgress.flags & 256 ? workInProgress : null;
58415841
}
58425842
if (0 !== (workInProgress.flags & 128))
58435843
return (workInProgress.lanes = renderLanes), workInProgress;
@@ -9496,7 +9496,7 @@ var roots = new Map(),
94969496
devToolsConfig$jscomp$inline_1033 = {
94979497
findFiberByHostInstance: getInstanceFromNode,
94989498
bundleType: 0,
9499-
version: "18.3.0-next-520f7f3ed-20230320",
9499+
version: "18.3.0-next-77ba1618a-20230320",
95009500
rendererPackageName: "react-native-renderer",
95019501
rendererConfig: {
95029502
getInspectorDataForViewTag: function () {
@@ -9538,7 +9538,7 @@ var internals$jscomp$inline_1276 = {
95389538
scheduleRoot: null,
95399539
setRefreshHandler: null,
95409540
getCurrentFiber: null,
9541-
reconcilerVersion: "18.3.0-next-520f7f3ed-20230320"
9541+
reconcilerVersion: "18.3.0-next-77ba1618a-20230320"
95429542
};
95439543
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
95449544
var hook$jscomp$inline_1277 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6107,7 +6107,7 @@ function completeWork(current, workInProgress, renderLanes) {
61076107
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
61086108
(currentInstance = !0);
61096109
if (!currentInstance)
6110-
return workInProgress.flags & 65536 ? workInProgress : null;
6110+
return workInProgress.flags & 256 ? workInProgress : null;
61116111
}
61126112
if (0 !== (workInProgress.flags & 128))
61136113
return (
@@ -10206,7 +10206,7 @@ var roots = new Map(),
1020610206
devToolsConfig$jscomp$inline_1110 = {
1020710207
findFiberByHostInstance: getInstanceFromNode,
1020810208
bundleType: 0,
10209-
version: "18.3.0-next-520f7f3ed-20230320",
10209+
version: "18.3.0-next-77ba1618a-20230320",
1021010210
rendererPackageName: "react-native-renderer",
1021110211
rendererConfig: {
1021210212
getInspectorDataForViewTag: function () {
@@ -10261,7 +10261,7 @@ var roots = new Map(),
1026110261
scheduleRoot: null,
1026210262
setRefreshHandler: null,
1026310263
getCurrentFiber: null,
10264-
reconcilerVersion: "18.3.0-next-520f7f3ed-20230320"
10264+
reconcilerVersion: "18.3.0-next-77ba1618a-20230320"
1026510265
});
1026610266
exports.createPortal = function (children, containerTag) {
1026710267
return createPortal$1(

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19347,7 +19347,7 @@ function completeWork(current, workInProgress, renderLanes) {
1934719347
);
1934819348

1934919349
if (!fallthroughToNormalSuspensePath) {
19350-
if (workInProgress.flags & ShouldCapture) {
19350+
if (workInProgress.flags & ForceClientRender) {
1935119351
// Special case. There were remaining unhydrated nodes. We treat
1935219352
// this as a mismatch. Revert to client rendering.
1935319353
return workInProgress;
@@ -27393,7 +27393,7 @@ function createFiberRoot(
2739327393
return root;
2739427394
}
2739527395

27396-
var ReactVersion = "18.3.0-next-520f7f3ed-20230320";
27396+
var ReactVersion = "18.3.0-next-77ba1618a-20230320";
2739727397

2739827398
function createPortal$1(
2739927399
children,

0 commit comments

Comments
 (0)