Skip to content

Commit e49ae82

Browse files
committed
[Fiber] Mark hydrated components in tertiary color (green) (#31829)
This is a follow up to #31752. This keeps track in the commit phase whether this subtree was hydrated. If it was, then we mark those components in the Components track as green. Just like the phase itself is marked as green. If the boundary client rendered we instead mark it as "errored" and its children given the plain primary render color (blue). I also collect the hydration error for this case so we can include its message in the details view. (Unfortunately this doesn't support newlines atm.) Most of the time this happens in separate commits for each boundary but it is possible to force a client render in the same pass as a hydration. Such as if an update flows into a boundary that has been put into fallback state after it was initially attempted. <img width="1487" alt="Screenshot 2024-12-18 at 12 06 54 AM" src="https://github.com/user-attachments/assets/74c57291-4d11-414c-9751-3dac3285a89a" /> DiffTrain build for [17520b6](17520b6)
1 parent 96ca300 commit e49ae82

34 files changed

+2950
-2484
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
95465dc4913377ab7e2fa98d956c87adb5e38e6c
1+
17520b638190a20e745fe53299813b29b52dfc4c
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
95465dc4913377ab7e2fa98d956c87adb5e38e6c
1+
17520b638190a20e745fe53299813b29b52dfc4c

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ __DEV__ &&
19421942
exports.useTransition = function () {
19431943
return resolveDispatcher().useTransition();
19441944
};
1945-
exports.version = "19.1.0-www-classic-95465dc4-20241218";
1945+
exports.version = "19.1.0-www-classic-17520b63-20241218";
19461946
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19471947
"function" ===
19481948
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ __DEV__ &&
19421942
exports.useTransition = function () {
19431943
return resolveDispatcher().useTransition();
19441944
};
1945-
exports.version = "19.1.0-www-modern-95465dc4-20241218";
1945+
exports.version = "19.1.0-www-modern-17520b63-20241218";
19461946
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19471947
"function" ===
19481948
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-classic-95465dc4-20241218";
633+
exports.version = "19.1.0-www-classic-17520b63-20241218";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-modern-95465dc4-20241218";
633+
exports.version = "19.1.0-www-modern-17520b63-20241218";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-classic-95465dc4-20241218";
637+
exports.version = "19.1.0-www-classic-17520b63-20241218";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-modern-95465dc4-20241218";
637+
exports.version = "19.1.0-www-modern-17520b63-20241218";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,18 @@ __DEV__ &&
19841984
));
19851985
return skipToNode + debugInfo + propName;
19861986
}
1987+
function upgradeHydrationErrorsToRecoverable() {
1988+
var queuedErrors = hydrationErrors;
1989+
null !== queuedErrors &&
1990+
(null === workInProgressRootRecoverableErrors
1991+
? (workInProgressRootRecoverableErrors = queuedErrors)
1992+
: workInProgressRootRecoverableErrors.push.apply(
1993+
workInProgressRootRecoverableErrors,
1994+
queuedErrors
1995+
),
1996+
(hydrationErrors = null));
1997+
return queuedErrors;
1998+
}
19871999
function resetContextDependencies() {
19882000
lastContextDependency = currentlyRenderingFiber$1 = null;
19892001
isDisallowedContextReadInDEV = !1;
@@ -9013,9 +9025,7 @@ __DEV__ &&
90139025
(current.memoizedState.isDehydrated &&
90149026
0 === (workInProgress.flags & 256)) ||
90159027
((workInProgress.flags |= 1024),
9016-
null !== hydrationErrors &&
9017-
(queueRecoverableErrors(hydrationErrors),
9018-
(hydrationErrors = null))),
9028+
upgradeHydrationErrorsToRecoverable()),
90199029
bubbleProperties(workInProgress),
90209030
enableTransitionTracing &&
90219031
0 !== (workInProgress.subtreeFlags & 8192) &&
@@ -9160,9 +9170,12 @@ __DEV__ &&
91609170
fallthroughToNormalSuspensePath.treeBaseDuration));
91619171
fallthroughToNormalSuspensePath = !1;
91629172
} else
9163-
null !== hydrationErrors &&
9164-
(queueRecoverableErrors(hydrationErrors),
9165-
(hydrationErrors = null)),
9173+
(fallthroughToNormalSuspensePath =
9174+
upgradeHydrationErrorsToRecoverable()),
9175+
null !== current &&
9176+
null !== current.memoizedState &&
9177+
(current.memoizedState.hydrationErrors =
9178+
fallthroughToNormalSuspensePath),
91669179
(fallthroughToNormalSuspensePath = !0);
91679180
if (!fallthroughToNormalSuspensePath) {
91689181
if (workInProgress.flags & 256)
@@ -11696,6 +11709,14 @@ __DEV__ &&
1169611709
committedTransitions
1169711710
);
1169811711
break;
11712+
case 13:
11713+
recursivelyTraversePassiveMountEffects(
11714+
finishedRoot,
11715+
finishedWork,
11716+
committedLanes,
11717+
committedTransitions
11718+
);
11719+
break;
1169911720
case 23:
1170011721
recursivelyTraversePassiveMountEffects(
1170111722
finishedRoot,
@@ -12434,7 +12455,13 @@ __DEV__ &&
1243412455
}
1243512456
exitStatus = workInProgressRootRecoverableErrors;
1243612457
workInProgressRootRecoverableErrors = lanesThatJustErrored;
12437-
null !== exitStatus && queueRecoverableErrors(exitStatus);
12458+
null !== exitStatus &&
12459+
(null === workInProgressRootRecoverableErrors
12460+
? (workInProgressRootRecoverableErrors = exitStatus)
12461+
: workInProgressRootRecoverableErrors.push.apply(
12462+
workInProgressRootRecoverableErrors,
12463+
exitStatus
12464+
));
1243812465
}
1243912466
exitStatus = renderWasConcurrent;
1244012467
}
@@ -12571,14 +12598,6 @@ __DEV__ &&
1257112598
} while (1);
1257212599
ensureRootIsScheduled(root);
1257312600
}
12574-
function queueRecoverableErrors(errors) {
12575-
null === workInProgressRootRecoverableErrors
12576-
? (workInProgressRootRecoverableErrors = errors)
12577-
: workInProgressRootRecoverableErrors.push.apply(
12578-
workInProgressRootRecoverableErrors,
12579-
errors
12580-
);
12581-
}
1258212601
function commitRootWhenReady(
1258312602
root,
1258412603
finishedWork,
@@ -16546,7 +16565,12 @@ __DEV__ &&
1654616565
var didWarnAboutTailOptions = {};
1654716566
var didWarnAboutDefaultPropsOnFunctionComponent = {};
1654816567
var updateLegacyHiddenComponent = updateOffscreenComponent,
16549-
SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 },
16568+
SUSPENDED_MARKER = {
16569+
dehydrated: null,
16570+
treeContext: null,
16571+
retryLane: 0,
16572+
hydrationErrors: null
16573+
},
1655016574
hasWarnedAboutUsingNoValuePropOnContextProvider = !1,
1655116575
emptyObject = {},
1655216576
didWarnAboutUndefinedSnapshotBeforeUpdate = null;
@@ -16870,10 +16894,10 @@ __DEV__ &&
1687016894
(function () {
1687116895
var internals = {
1687216896
bundleType: 1,
16873-
version: "19.1.0-www-classic-95465dc4-20241218",
16897+
version: "19.1.0-www-classic-17520b63-20241218",
1687416898
rendererPackageName: "react-art",
1687516899
currentDispatcherRef: ReactSharedInternals,
16876-
reconcilerVersion: "19.1.0-www-classic-95465dc4-20241218"
16900+
reconcilerVersion: "19.1.0-www-classic-17520b63-20241218"
1687716901
};
1687816902
internals.overrideHookState = overrideHookState;
1687916903
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16907,7 +16931,7 @@ __DEV__ &&
1690716931
exports.Shape = Shape;
1690816932
exports.Surface = Surface;
1690916933
exports.Text = Text;
16910-
exports.version = "19.1.0-www-classic-95465dc4-20241218";
16934+
exports.version = "19.1.0-www-classic-17520b63-20241218";
1691116935
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1691216936
"function" ===
1691316937
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,18 @@ __DEV__ &&
18761876
));
18771877
return skipToNode + debugInfo + propName;
18781878
}
1879+
function upgradeHydrationErrorsToRecoverable() {
1880+
var queuedErrors = hydrationErrors;
1881+
null !== queuedErrors &&
1882+
(null === workInProgressRootRecoverableErrors
1883+
? (workInProgressRootRecoverableErrors = queuedErrors)
1884+
: workInProgressRootRecoverableErrors.push.apply(
1885+
workInProgressRootRecoverableErrors,
1886+
queuedErrors
1887+
),
1888+
(hydrationErrors = null));
1889+
return queuedErrors;
1890+
}
18791891
function resetContextDependencies() {
18801892
lastContextDependency = currentlyRenderingFiber$1 = null;
18811893
isDisallowedContextReadInDEV = !1;
@@ -8825,9 +8837,7 @@ __DEV__ &&
88258837
(current.memoizedState.isDehydrated &&
88268838
0 === (workInProgress.flags & 256)) ||
88278839
((workInProgress.flags |= 1024),
8828-
null !== hydrationErrors &&
8829-
(queueRecoverableErrors(hydrationErrors),
8830-
(hydrationErrors = null))),
8840+
upgradeHydrationErrorsToRecoverable()),
88318841
bubbleProperties(workInProgress),
88328842
enableTransitionTracing &&
88338843
0 !== (workInProgress.subtreeFlags & 8192) &&
@@ -8972,9 +8982,12 @@ __DEV__ &&
89728982
fallthroughToNormalSuspensePath.treeBaseDuration));
89738983
fallthroughToNormalSuspensePath = !1;
89748984
} else
8975-
null !== hydrationErrors &&
8976-
(queueRecoverableErrors(hydrationErrors),
8977-
(hydrationErrors = null)),
8985+
(fallthroughToNormalSuspensePath =
8986+
upgradeHydrationErrorsToRecoverable()),
8987+
null !== current &&
8988+
null !== current.memoizedState &&
8989+
(current.memoizedState.hydrationErrors =
8990+
fallthroughToNormalSuspensePath),
89788991
(fallthroughToNormalSuspensePath = !0);
89798992
if (!fallthroughToNormalSuspensePath) {
89808993
if (workInProgress.flags & 256)
@@ -11500,6 +11513,14 @@ __DEV__ &&
1150011513
committedTransitions
1150111514
);
1150211515
break;
11516+
case 13:
11517+
recursivelyTraversePassiveMountEffects(
11518+
finishedRoot,
11519+
finishedWork,
11520+
committedLanes,
11521+
committedTransitions
11522+
);
11523+
break;
1150311524
case 23:
1150411525
recursivelyTraversePassiveMountEffects(
1150511526
finishedRoot,
@@ -12238,7 +12259,13 @@ __DEV__ &&
1223812259
}
1223912260
exitStatus = workInProgressRootRecoverableErrors;
1224012261
workInProgressRootRecoverableErrors = lanesThatJustErrored;
12241-
null !== exitStatus && queueRecoverableErrors(exitStatus);
12262+
null !== exitStatus &&
12263+
(null === workInProgressRootRecoverableErrors
12264+
? (workInProgressRootRecoverableErrors = exitStatus)
12265+
: workInProgressRootRecoverableErrors.push.apply(
12266+
workInProgressRootRecoverableErrors,
12267+
exitStatus
12268+
));
1224212269
}
1224312270
exitStatus = renderWasConcurrent;
1224412271
}
@@ -12375,14 +12402,6 @@ __DEV__ &&
1237512402
} while (1);
1237612403
ensureRootIsScheduled(root);
1237712404
}
12378-
function queueRecoverableErrors(errors) {
12379-
null === workInProgressRootRecoverableErrors
12380-
? (workInProgressRootRecoverableErrors = errors)
12381-
: workInProgressRootRecoverableErrors.push.apply(
12382-
workInProgressRootRecoverableErrors,
12383-
errors
12384-
);
12385-
}
1238612405
function commitRootWhenReady(
1238712406
root,
1238812407
finishedWork,
@@ -16309,7 +16328,12 @@ __DEV__ &&
1630916328
var didWarnAboutTailOptions = {};
1631016329
var didWarnAboutDefaultPropsOnFunctionComponent = {};
1631116330
var updateLegacyHiddenComponent = updateOffscreenComponent,
16312-
SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 },
16331+
SUSPENDED_MARKER = {
16332+
dehydrated: null,
16333+
treeContext: null,
16334+
retryLane: 0,
16335+
hydrationErrors: null
16336+
},
1631316337
hasWarnedAboutUsingNoValuePropOnContextProvider = !1,
1631416338
emptyObject = {},
1631516339
didWarnAboutUndefinedSnapshotBeforeUpdate = null;
@@ -16633,10 +16657,10 @@ __DEV__ &&
1663316657
(function () {
1663416658
var internals = {
1663516659
bundleType: 1,
16636-
version: "19.1.0-www-modern-95465dc4-20241218",
16660+
version: "19.1.0-www-modern-17520b63-20241218",
1663716661
rendererPackageName: "react-art",
1663816662
currentDispatcherRef: ReactSharedInternals,
16639-
reconcilerVersion: "19.1.0-www-modern-95465dc4-20241218"
16663+
reconcilerVersion: "19.1.0-www-modern-17520b63-20241218"
1664016664
};
1664116665
internals.overrideHookState = overrideHookState;
1664216666
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16670,7 +16694,7 @@ __DEV__ &&
1667016694
exports.Shape = Shape;
1667116695
exports.Surface = Surface;
1667216696
exports.Text = Text;
16673-
exports.version = "19.1.0-www-modern-95465dc4-20241218";
16697+
exports.version = "19.1.0-www-modern-17520b63-20241218";
1667416698
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1667516699
"function" ===
1667616700
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)