Skip to content

Commit 7d53888

Browse files
committed
Move tail hydration mismatch back to hydration context (#28501)
In #23176 we added a special case in completeWork for SuspenseBoundaries if they still have trailing children. However, that misses a case because it doesn't log a recoverable error for the hydration mismatch. So we get an error that we rerendered. I think this special case was done to avoid contexts getting out of sync. I don't know why we didn't just move where the pop happens though so that's what I did here and let the regular pass throw instead. Seems to be pass the tests. DiffTrain build for commit c11b196.
1 parent 010c604 commit 7d53888

File tree

13 files changed

+88
-51
lines changed

13 files changed

+88
-51
lines changed

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

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

1313
"use strict";
@@ -17075,7 +17075,6 @@ if (__DEV__) {
1707517075
}
1707617076

1707717077
case SuspenseComponent: {
17078-
popSuspenseHandler(workInProgress);
1707917078
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
1708017079
// to its own fiber type so that we can add other kinds of hydration
1708117080
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -17096,17 +17095,21 @@ if (__DEV__) {
1709617095

1709717096
if (!fallthroughToNormalSuspensePath) {
1709817097
if (workInProgress.flags & ForceClientRender) {
17099-
// Special case. There were remaining unhydrated nodes. We treat
17098+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
1710017099
// this as a mismatch. Revert to client rendering.
17100+
1710117101
return workInProgress;
1710217102
} else {
17103-
// Did not finish hydrating, either because this is the initial
17103+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
1710417104
// render or because something suspended.
17105+
1710517106
return null;
1710617107
}
1710717108
} // Continue with the normal Suspense path.
1710817109
}
1710917110

17111+
popSuspenseHandler(workInProgress);
17112+
1711017113
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
1711117114
// Something suspended. Re-render with the fallback children.
1711217115
workInProgress.lanes = renderLanes; // Do not reset the effect list.
@@ -25733,7 +25736,7 @@ if (__DEV__) {
2573325736
return root;
2573425737
}
2573525738

25736-
var ReactVersion = "18.3.0-canary-966d17483-20240305";
25739+
var ReactVersion = "18.3.0-canary-c11b196ae-20240305";
2573725740

2573825741
// Might add PROFILE later.
2573925742

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

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

1313
"use strict";
@@ -5256,7 +5256,6 @@ function completeWork(current, workInProgress, renderLanes) {
52565256
bubbleProperties(workInProgress);
52575257
return null;
52585258
case 13:
5259-
popSuspenseHandler(workInProgress);
52605259
newProps = workInProgress.memoizedState;
52615260
if (
52625261
null === current ||
@@ -5281,8 +5280,14 @@ function completeWork(current, workInProgress, renderLanes) {
52815280
null !== hydrationErrors &&
52825281
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
52835282
(index = !0);
5284-
if (!index) return workInProgress.flags & 256 ? workInProgress : null;
5283+
if (!index) {
5284+
if (workInProgress.flags & 256)
5285+
return popSuspenseHandler(workInProgress), workInProgress;
5286+
popSuspenseHandler(workInProgress);
5287+
return null;
5288+
}
52855289
}
5290+
popSuspenseHandler(workInProgress);
52865291
if (0 !== (workInProgress.flags & 128))
52875292
return (workInProgress.lanes = renderLanes), workInProgress;
52885293
renderLanes = null !== newProps;
@@ -9173,7 +9178,7 @@ var devToolsConfig$jscomp$inline_1014 = {
91739178
throw Error("TestRenderer does not support findFiberByHostInstance()");
91749179
},
91759180
bundleType: 0,
9176-
version: "18.3.0-canary-966d17483-20240305",
9181+
version: "18.3.0-canary-c11b196ae-20240305",
91779182
rendererPackageName: "react-test-renderer"
91789183
};
91799184
var internals$jscomp$inline_1195 = {
@@ -9204,7 +9209,7 @@ var internals$jscomp$inline_1195 = {
92049209
scheduleRoot: null,
92059210
setRefreshHandler: null,
92069211
getCurrentFiber: null,
9207-
reconcilerVersion: "18.3.0-canary-966d17483-20240305"
9212+
reconcilerVersion: "18.3.0-canary-c11b196ae-20240305"
92089213
};
92099214
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
92109215
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

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

1313
"use strict";
@@ -5398,7 +5398,6 @@ function completeWork(current, workInProgress, renderLanes) {
53985398
bubbleProperties(workInProgress);
53995399
return null;
54005400
case 13:
5401-
popSuspenseHandler(workInProgress);
54025401
newProps = workInProgress.memoizedState;
54035402
if (
54045403
null === current ||
@@ -5428,8 +5427,14 @@ function completeWork(current, workInProgress, renderLanes) {
54285427
null !== hydrationErrors &&
54295428
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
54305429
(index = !0);
5431-
if (!index) return workInProgress.flags & 256 ? workInProgress : null;
5430+
if (!index) {
5431+
if (workInProgress.flags & 256)
5432+
return popSuspenseHandler(workInProgress), workInProgress;
5433+
popSuspenseHandler(workInProgress);
5434+
return null;
5435+
}
54325436
}
5437+
popSuspenseHandler(workInProgress);
54335438
if (0 !== (workInProgress.flags & 128))
54345439
return (
54355440
(workInProgress.lanes = renderLanes),
@@ -9601,7 +9606,7 @@ var devToolsConfig$jscomp$inline_1056 = {
96019606
throw Error("TestRenderer does not support findFiberByHostInstance()");
96029607
},
96039608
bundleType: 0,
9604-
version: "18.3.0-canary-966d17483-20240305",
9609+
version: "18.3.0-canary-c11b196ae-20240305",
96059610
rendererPackageName: "react-test-renderer"
96069611
};
96079612
var internals$jscomp$inline_1236 = {
@@ -9632,7 +9637,7 @@ var internals$jscomp$inline_1236 = {
96329637
scheduleRoot: null,
96339638
setRefreshHandler: null,
96349639
getCurrentFiber: null,
9635-
reconcilerVersion: "18.3.0-canary-966d17483-20240305"
9640+
reconcilerVersion: "18.3.0-canary-c11b196ae-20240305"
96369641
};
96379642
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96389643
var hook$jscomp$inline_1237 = __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
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "18.3.0-canary-966d17483-20240305";
29+
var ReactVersion = "18.3.0-canary-c11b196ae-20240305";
3030

3131
// ATTENTION
3232
// 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
@@ -598,4 +598,4 @@ exports.useSyncExternalStore = function (
598598
exports.useTransition = function () {
599599
return ReactCurrentDispatcher.current.useTransition();
600600
};
601-
exports.version = "18.3.0-canary-966d17483-20240305";
601+
exports.version = "18.3.0-canary-c11b196ae-20240305";

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
@@ -594,7 +594,7 @@ exports.useSyncExternalStore = function (
594594
exports.useTransition = function () {
595595
return ReactCurrentDispatcher.current.useTransition();
596596
};
597-
exports.version = "18.3.0-canary-966d17483-20240305";
597+
exports.version = "18.3.0-canary-c11b196ae-20240305";
598598
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
599599
"function" ===
600600
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
966d17483c2a628fda36794bc193c7ad2c3124eb
1+
c11b196ae3e2e3c5d143d9102b35a6b6fa97c849

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

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

1313
"use strict";
@@ -20208,7 +20208,6 @@ to return true:wantsResponderID| |
2020820208
}
2020920209

2021020210
case SuspenseComponent: {
20211-
popSuspenseHandler(workInProgress);
2021220211
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
2021320212
// to its own fiber type so that we can add other kinds of hydration
2021420213
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -20229,17 +20228,21 @@ to return true:wantsResponderID| |
2022920228

2023020229
if (!fallthroughToNormalSuspensePath) {
2023120230
if (workInProgress.flags & ForceClientRender) {
20232-
// Special case. There were remaining unhydrated nodes. We treat
20231+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
2023320232
// this as a mismatch. Revert to client rendering.
20233+
2023420234
return workInProgress;
2023520235
} else {
20236-
// Did not finish hydrating, either because this is the initial
20236+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
2023720237
// render or because something suspended.
20238+
2023820239
return null;
2023920240
}
2024020241
} // Continue with the normal Suspense path.
2024120242
}
2024220243

20244+
popSuspenseHandler(workInProgress);
20245+
2024320246
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
2024420247
// Something suspended. Re-render with the fallback children.
2024520248
workInProgress.lanes = renderLanes; // Do not reset the effect list.
@@ -28088,7 +28091,7 @@ to return true:wantsResponderID| |
2808828091
return root;
2808928092
}
2809028093

28091-
var ReactVersion = "18.3.0-canary-d0bc2995";
28094+
var ReactVersion = "18.3.0-canary-d679cfa2";
2809228095

2809328096
function createPortal$1(
2809428097
children,

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

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

1313
"use strict";
@@ -6436,7 +6436,6 @@ function completeWork(current, workInProgress, renderLanes) {
64366436
bubbleProperties(workInProgress);
64376437
return null;
64386438
case 13:
6439-
popSuspenseHandler(workInProgress);
64406439
newProps = workInProgress.memoizedState;
64416440
if (
64426441
null === current ||
@@ -6461,9 +6460,14 @@ function completeWork(current, workInProgress, renderLanes) {
64616460
null !== hydrationErrors &&
64626461
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
64636462
(oldProps = !0);
6464-
if (!oldProps)
6465-
return workInProgress.flags & 256 ? workInProgress : null;
6463+
if (!oldProps) {
6464+
if (workInProgress.flags & 256)
6465+
return popSuspenseHandler(workInProgress), workInProgress;
6466+
popSuspenseHandler(workInProgress);
6467+
return null;
6468+
}
64666469
}
6470+
popSuspenseHandler(workInProgress);
64676471
if (0 !== (workInProgress.flags & 128))
64686472
return (workInProgress.lanes = renderLanes), workInProgress;
64696473
newProps = null !== newProps;
@@ -9707,7 +9711,7 @@ var roots = new Map(),
97079711
devToolsConfig$jscomp$inline_1059 = {
97089712
findFiberByHostInstance: getInstanceFromNode,
97099713
bundleType: 0,
9710-
version: "18.3.0-canary-2f8f605b",
9714+
version: "18.3.0-canary-f799fa3f",
97119715
rendererPackageName: "react-native-renderer",
97129716
rendererConfig: {
97139717
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -9750,7 +9754,7 @@ var internals$jscomp$inline_1284 = {
97509754
scheduleRoot: null,
97519755
setRefreshHandler: null,
97529756
getCurrentFiber: null,
9753-
reconcilerVersion: "18.3.0-canary-2f8f605b"
9757+
reconcilerVersion: "18.3.0-canary-f799fa3f"
97549758
};
97559759
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
97569760
var hook$jscomp$inline_1285 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

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

1313
"use strict";
@@ -6698,7 +6698,6 @@ function completeWork(current, workInProgress, renderLanes) {
66986698
bubbleProperties(workInProgress);
66996699
return null;
67006700
case 13:
6701-
popSuspenseHandler(workInProgress);
67026701
newProps = workInProgress.memoizedState;
67036702
if (
67046703
null === current ||
@@ -6728,9 +6727,14 @@ function completeWork(current, workInProgress, renderLanes) {
67286727
null !== hydrationErrors &&
67296728
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
67306729
(oldProps = !0);
6731-
if (!oldProps)
6732-
return workInProgress.flags & 256 ? workInProgress : null;
6730+
if (!oldProps) {
6731+
if (workInProgress.flags & 256)
6732+
return popSuspenseHandler(workInProgress), workInProgress;
6733+
popSuspenseHandler(workInProgress);
6734+
return null;
6735+
}
67336736
}
6737+
popSuspenseHandler(workInProgress);
67346738
if (0 !== (workInProgress.flags & 128))
67356739
return (
67366740
(workInProgress.lanes = renderLanes),
@@ -10409,7 +10413,7 @@ var roots = new Map(),
1040910413
devToolsConfig$jscomp$inline_1137 = {
1041010414
findFiberByHostInstance: getInstanceFromNode,
1041110415
bundleType: 0,
10412-
version: "18.3.0-canary-f48f6d2a",
10416+
version: "18.3.0-canary-3a92e945",
1041310417
rendererPackageName: "react-native-renderer",
1041410418
rendererConfig: {
1041510419
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10465,7 +10469,7 @@ var roots = new Map(),
1046510469
scheduleRoot: null,
1046610470
setRefreshHandler: null,
1046710471
getCurrentFiber: null,
10468-
reconcilerVersion: "18.3.0-canary-f48f6d2a"
10472+
reconcilerVersion: "18.3.0-canary-3a92e945"
1046910473
});
1047010474
exports.createPortal = function (children, containerTag) {
1047110475
return createPortal$1(

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

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

1313
"use strict";
@@ -20250,7 +20250,6 @@ to return true:wantsResponderID| |
2025020250
}
2025120251

2025220252
case SuspenseComponent: {
20253-
popSuspenseHandler(workInProgress);
2025420253
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
2025520254
// to its own fiber type so that we can add other kinds of hydration
2025620255
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -20271,17 +20270,21 @@ to return true:wantsResponderID| |
2027120270

2027220271
if (!fallthroughToNormalSuspensePath) {
2027320272
if (workInProgress.flags & ForceClientRender) {
20274-
// Special case. There were remaining unhydrated nodes. We treat
20273+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
2027520274
// this as a mismatch. Revert to client rendering.
20275+
2027620276
return workInProgress;
2027720277
} else {
20278-
// Did not finish hydrating, either because this is the initial
20278+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
2027920279
// render or because something suspended.
20280+
2028020281
return null;
2028120282
}
2028220283
} // Continue with the normal Suspense path.
2028320284
}
2028420285

20286+
popSuspenseHandler(workInProgress);
20287+
2028520288
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
2028620289
// Something suspended. Re-render with the fallback children.
2028720290
workInProgress.lanes = renderLanes; // Do not reset the effect list.
@@ -28528,7 +28531,7 @@ to return true:wantsResponderID| |
2852828531
return root;
2852928532
}
2853028533

28531-
var ReactVersion = "18.3.0-canary-aba998f4";
28534+
var ReactVersion = "18.3.0-canary-469281c1";
2853228535

2853328536
function createPortal$1(
2853428537
children,

0 commit comments

Comments
 (0)