Skip to content

Commit 401192f

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 [c11b196](c11b196)
1 parent 6cf536e commit 401192f

19 files changed

+357
-445
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
113ab9af08c46e8a548a397154f5c9dfeb96ab6a
1+
c11b196ae3e2e3c5d143d9102b35a6b6fa97c849

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,4 +633,4 @@ exports.useSyncExternalStore = function (
633633
exports.useTransition = function () {
634634
return ReactCurrentDispatcher.current.useTransition();
635635
};
636-
exports.version = "18.3.0-www-classic-f938cefa";
636+
exports.version = "18.3.0-www-classic-5741f0db";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ exports.useSyncExternalStore = function (
637637
exports.useTransition = function () {
638638
return ReactCurrentDispatcher.current.useTransition();
639639
};
640-
exports.version = "18.3.0-www-classic-c1c1744a";
640+
exports.version = "18.3.0-www-classic-6ddd4df1";
641641
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
642642
"function" ===
643643
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-classic-20a604bc";
69+
var ReactVersion = "18.3.0-www-classic-14143ab0";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -19974,7 +19974,6 @@ if (__DEV__) {
1997419974
}
1997519975

1997619976
case SuspenseComponent: {
19977-
popSuspenseHandler(workInProgress);
1997819977
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
1997919978
// to its own fiber type so that we can add other kinds of hydration
1998019979
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -19995,17 +19994,21 @@ if (__DEV__) {
1999519994

1999619995
if (!fallthroughToNormalSuspensePath) {
1999719996
if (workInProgress.flags & ForceClientRender) {
19998-
// Special case. There were remaining unhydrated nodes. We treat
19997+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
1999919998
// this as a mismatch. Revert to client rendering.
19999+
2000020000
return workInProgress;
2000120001
} else {
20002-
// Did not finish hydrating, either because this is the initial
20002+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
2000320003
// render or because something suspended.
20004+
2000420005
return null;
2000520006
}
2000620007
} // Continue with the normal Suspense path.
2000720008
}
2000820009

20010+
popSuspenseHandler(workInProgress);
20011+
2000920012
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
2001020013
// Something suspended. Re-render with the fallback children.
2001120014
workInProgress.lanes = renderLanes; // Do not reset the effect list.

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-modern-c0bbf979";
69+
var ReactVersion = "18.3.0-www-modern-0883d4be";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -19655,7 +19655,6 @@ if (__DEV__) {
1965519655
}
1965619656

1965719657
case SuspenseComponent: {
19658-
popSuspenseHandler(workInProgress);
1965919658
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
1966019659
// to its own fiber type so that we can add other kinds of hydration
1966119660
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -19676,17 +19675,21 @@ if (__DEV__) {
1967619675

1967719676
if (!fallthroughToNormalSuspensePath) {
1967819677
if (workInProgress.flags & ForceClientRender) {
19679-
// Special case. There were remaining unhydrated nodes. We treat
19678+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
1968019679
// this as a mismatch. Revert to client rendering.
19680+
1968119681
return workInProgress;
1968219682
} else {
19683-
// Did not finish hydrating, either because this is the initial
19683+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
1968419684
// render or because something suspended.
19685+
1968519686
return null;
1968619687
}
1968719688
} // Continue with the normal Suspense path.
1968819689
}
1968919690

19691+
popSuspenseHandler(workInProgress);
19692+
1969019693
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
1969119694
// Something suspended. Re-render with the fallback children.
1969219695
workInProgress.lanes = renderLanes; // Do not reset the effect list.

compiled/facebook-www/ReactART-prod.classic.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6253,7 +6253,6 @@ function completeWork(current, workInProgress, renderLanes) {
62536253
bubbleProperties(workInProgress);
62546254
return null;
62556255
case 13:
6256-
popSuspenseHandler(workInProgress);
62576256
newProps = workInProgress.memoizedState;
62586257
if (
62596258
null === current ||
@@ -6274,9 +6273,14 @@ function completeWork(current, workInProgress, renderLanes) {
62746273
null !== hydrationErrors &&
62756274
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
62766275
(instance = !0);
6277-
if (!instance)
6278-
return workInProgress.flags & 256 ? workInProgress : null;
6276+
if (!instance) {
6277+
if (workInProgress.flags & 256)
6278+
return popSuspenseHandler(workInProgress), workInProgress;
6279+
popSuspenseHandler(workInProgress);
6280+
return null;
6281+
}
62796282
}
6283+
popSuspenseHandler(workInProgress);
62806284
if (0 !== (workInProgress.flags & 128))
62816285
return (workInProgress.lanes = renderLanes), workInProgress;
62826286
renderLanes = null !== newProps;
@@ -10596,7 +10600,7 @@ var slice = Array.prototype.slice,
1059610600
return null;
1059710601
},
1059810602
bundleType: 0,
10599-
version: "18.3.0-www-classic-0f4883c5",
10603+
version: "18.3.0-www-classic-cad557f7",
1060010604
rendererPackageName: "react-art"
1060110605
};
1060210606
var internals$jscomp$inline_1320 = {
@@ -10627,7 +10631,7 @@ var internals$jscomp$inline_1320 = {
1062710631
scheduleRoot: null,
1062810632
setRefreshHandler: null,
1062910633
getCurrentFiber: null,
10630-
reconcilerVersion: "18.3.0-www-classic-0f4883c5"
10634+
reconcilerVersion: "18.3.0-www-classic-cad557f7"
1063110635
};
1063210636
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1063310637
var hook$jscomp$inline_1321 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactART-prod.modern.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5992,7 +5992,6 @@ function completeWork(current, workInProgress, renderLanes) {
59925992
bubbleProperties(workInProgress);
59935993
return null;
59945994
case 13:
5995-
popSuspenseHandler(workInProgress);
59965995
newProps = workInProgress.memoizedState;
59975996
if (
59985997
null === current ||
@@ -6013,9 +6012,14 @@ function completeWork(current, workInProgress, renderLanes) {
60136012
null !== hydrationErrors &&
60146013
(queueRecoverableErrors(hydrationErrors), (hydrationErrors = null)),
60156014
(instance = !0);
6016-
if (!instance)
6017-
return workInProgress.flags & 256 ? workInProgress : null;
6015+
if (!instance) {
6016+
if (workInProgress.flags & 256)
6017+
return popSuspenseHandler(workInProgress), workInProgress;
6018+
popSuspenseHandler(workInProgress);
6019+
return null;
6020+
}
60186021
}
6022+
popSuspenseHandler(workInProgress);
60196023
if (0 !== (workInProgress.flags & 128))
60206024
return (workInProgress.lanes = renderLanes), workInProgress;
60216025
renderLanes = null !== newProps;
@@ -10251,7 +10255,7 @@ var slice = Array.prototype.slice,
1025110255
return null;
1025210256
},
1025310257
bundleType: 0,
10254-
version: "18.3.0-www-modern-1b51d894",
10258+
version: "18.3.0-www-modern-5c2d3ed7",
1025510259
rendererPackageName: "react-art"
1025610260
};
1025710261
var internals$jscomp$inline_1300 = {
@@ -10282,7 +10286,7 @@ var internals$jscomp$inline_1300 = {
1028210286
scheduleRoot: null,
1028310287
setRefreshHandler: null,
1028410288
getCurrentFiber: null,
10285-
reconcilerVersion: "18.3.0-www-modern-1b51d894"
10289+
reconcilerVersion: "18.3.0-www-modern-5c2d3ed7"
1028610290
};
1028710291
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1028810292
var hook$jscomp$inline_1301 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactDOM-dev.classic.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8941,10 +8941,6 @@ if (__DEV__) {
89418941
return true;
89428942
}
89438943

8944-
function hasUnhydratedTailNodes() {
8945-
return isHydrating && nextHydratableInstance !== null;
8946-
}
8947-
89488944
function warnIfUnhydratedTailNodes(fiber) {
89498945
var nextInstance = nextHydratableInstance;
89508946

@@ -24958,17 +24954,6 @@ if (__DEV__) {
2495824954
workInProgress,
2495924955
nextState
2496024956
) {
24961-
if (
24962-
hasUnhydratedTailNodes() &&
24963-
(workInProgress.mode & ConcurrentMode) !== NoMode &&
24964-
(workInProgress.flags & DidCapture) === NoFlags$1
24965-
) {
24966-
warnIfUnhydratedTailNodes(workInProgress);
24967-
resetHydrationState();
24968-
workInProgress.flags |= ForceClientRender | DidCapture;
24969-
return false;
24970-
}
24971-
2497224957
var wasHydrated = popHydrationState(workInProgress);
2497324958

2497424959
if (nextState !== null && nextState.dehydrated !== null) {
@@ -25405,7 +25390,6 @@ if (__DEV__) {
2540525390
}
2540625391

2540725392
case SuspenseComponent: {
25408-
popSuspenseHandler(workInProgress);
2540925393
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
2541025394
// to its own fiber type so that we can add other kinds of hydration
2541125395
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -25426,17 +25410,21 @@ if (__DEV__) {
2542625410

2542725411
if (!fallthroughToNormalSuspensePath) {
2542825412
if (workInProgress.flags & ForceClientRender) {
25429-
// Special case. There were remaining unhydrated nodes. We treat
25413+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
2543025414
// this as a mismatch. Revert to client rendering.
25415+
2543125416
return workInProgress;
2543225417
} else {
25433-
// Did not finish hydrating, either because this is the initial
25418+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
2543425419
// render or because something suspended.
25420+
2543525421
return null;
2543625422
}
2543725423
} // Continue with the normal Suspense path.
2543825424
}
2543925425

25426+
popSuspenseHandler(workInProgress);
25427+
2544025428
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
2544125429
// Something suspended. Re-render with the fallback children.
2544225430
workInProgress.lanes = renderLanes; // Do not reset the effect list.
@@ -36046,7 +36034,7 @@ if (__DEV__) {
3604636034
return root;
3604736035
}
3604836036

36049-
var ReactVersion = "18.3.0-www-classic-e13660d6";
36037+
var ReactVersion = "18.3.0-www-classic-78291ba2";
3605036038

3605136039
function createPortal$1(
3605236040
children,

compiled/facebook-www/ReactDOM-dev.modern.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8903,10 +8903,6 @@ if (__DEV__) {
89038903
return true;
89048904
}
89058905

8906-
function hasUnhydratedTailNodes() {
8907-
return isHydrating && nextHydratableInstance !== null;
8908-
}
8909-
89108906
function warnIfUnhydratedTailNodes(fiber) {
89118907
var nextInstance = nextHydratableInstance;
89128908

@@ -24843,17 +24839,6 @@ if (__DEV__) {
2484324839
workInProgress,
2484424840
nextState
2484524841
) {
24846-
if (
24847-
hasUnhydratedTailNodes() &&
24848-
(workInProgress.mode & ConcurrentMode) !== NoMode &&
24849-
(workInProgress.flags & DidCapture) === NoFlags$1
24850-
) {
24851-
warnIfUnhydratedTailNodes(workInProgress);
24852-
resetHydrationState();
24853-
workInProgress.flags |= ForceClientRender | DidCapture;
24854-
return false;
24855-
}
24856-
2485724842
var wasHydrated = popHydrationState(workInProgress);
2485824843

2485924844
if (nextState !== null && nextState.dehydrated !== null) {
@@ -25283,7 +25268,6 @@ if (__DEV__) {
2528325268
}
2528425269

2528525270
case SuspenseComponent: {
25286-
popSuspenseHandler(workInProgress);
2528725271
var nextState = workInProgress.memoizedState; // Special path for dehydrated boundaries. We may eventually move this
2528825272
// to its own fiber type so that we can add other kinds of hydration
2528925273
// boundaries that aren't associated with a Suspense tree. In anticipation
@@ -25304,17 +25288,21 @@ if (__DEV__) {
2530425288

2530525289
if (!fallthroughToNormalSuspensePath) {
2530625290
if (workInProgress.flags & ForceClientRender) {
25307-
// Special case. There were remaining unhydrated nodes. We treat
25291+
popSuspenseHandler(workInProgress); // Special case. There were remaining unhydrated nodes. We treat
2530825292
// this as a mismatch. Revert to client rendering.
25293+
2530925294
return workInProgress;
2531025295
} else {
25311-
// Did not finish hydrating, either because this is the initial
25296+
popSuspenseHandler(workInProgress); // Did not finish hydrating, either because this is the initial
2531225297
// render or because something suspended.
25298+
2531325299
return null;
2531425300
}
2531525301
} // Continue with the normal Suspense path.
2531625302
}
2531725303

25304+
popSuspenseHandler(workInProgress);
25305+
2531825306
if ((workInProgress.flags & DidCapture) !== NoFlags$1) {
2531925307
// Something suspended. Re-render with the fallback children.
2532025308
workInProgress.lanes = renderLanes; // Do not reset the effect list.
@@ -35893,7 +35881,7 @@ if (__DEV__) {
3589335881
return root;
3589435882
}
3589535883

35896-
var ReactVersion = "18.3.0-www-modern-06a38f42";
35884+
var ReactVersion = "18.3.0-www-modern-8a38254f";
3589735885

3589835886
function createPortal$1(
3589935887
children,

0 commit comments

Comments
 (0)