Skip to content

Commit 51f690d

Browse files
committed
[Fiber] Mark error boundaries and commit phases when an error is thrown (facebook#31876)
This tracks commit phase errors and marks the component that errored as red. These also get the errors attached to the entry. <img width="1505" alt="Screenshot 2024-12-20 at 2 40 14 PM" src="https://github.com/user-attachments/assets/cac3ead7-a024-4e33-ab27-2e95293c4299" /> In the render phase I just mark the Error Boundary that caught the error. We don't have access to the actual error since it's locked behind closures in the update queue. We could probably expose that someway. <img width="949" alt="Screenshot 2024-12-20 at 1 49 05 PM" src="https://github.com/user-attachments/assets/3032455d-d9f2-462b-9c07-7be23663ecd3" /> Follow ups: Since the Error Boundary doesn't commit its attempted render, we don't log those. If we did then maybe we should just mark the errored component like I do for the commit phase. We could potentially walk the list of errors and log the captured fibers and just log their entries as children. We could also potentially walk the uncommitted Fiber tree by stashing it somewhere or even getting it from the alternate. This could be done on Suspense boundaries too to track failed hydrations. --------- Co-authored-by: Ricky <[email protected]> DiffTrain build for [0de1233](facebook@0de1233)
1 parent cb063f1 commit 51f690d

34 files changed

+506
-266
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
99471c02dd6631df1892bf76d932afd22fffa5e3
1+
0de1233fd180969f7ffdfc98151922f2466ceb1f
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
99471c02dd6631df1892bf76d932afd22fffa5e3
1+
0de1233fd180969f7ffdfc98151922f2466ceb1f

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-99471c02-20241220";
1945+
exports.version = "19.1.0-www-classic-0de1233f-20250102";
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-99471c02-20241220";
1945+
exports.version = "19.1.0-www-modern-0de1233f-20250102";
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-99471c02-20241220";
633+
exports.version = "19.1.0-www-classic-0de1233f-20250102";

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-99471c02-20241220";
633+
exports.version = "19.1.0-www-modern-0de1233f-20250102";

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-99471c02-20241220";
637+
exports.version = "19.1.0-www-classic-0de1233f-20250102";
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-99471c02-20241220";
637+
exports.version = "19.1.0-www-modern-0de1233f-20250102";
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: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,11 +2289,9 @@ __DEV__ &&
22892289
mightHavePendingSyncWork = !0;
22902290
null !== ReactSharedInternals.actQueue
22912291
? didScheduleMicrotask_act ||
2292-
((didScheduleMicrotask_act = !0),
2293-
scheduleImmediateTask(processRootScheduleInMicrotask))
2292+
((didScheduleMicrotask_act = !0), scheduleImmediateRootScheduleTask())
22942293
: didScheduleMicrotask ||
2295-
((didScheduleMicrotask = !0),
2296-
scheduleImmediateTask(processRootScheduleInMicrotask));
2294+
((didScheduleMicrotask = !0), scheduleImmediateRootScheduleTask());
22972295
enableDeferRootSchedulingToMicrotask ||
22982296
scheduleTaskForRootDuringMicrotask(root, now$1());
22992297
}
@@ -2339,6 +2337,9 @@ __DEV__ &&
23392337
isFlushingWork = !1;
23402338
}
23412339
}
2340+
function processRootScheduleInImmediateTask() {
2341+
processRootScheduleInMicrotask();
2342+
}
23422343
function processRootScheduleInMicrotask() {
23432344
mightHavePendingSyncWork =
23442345
didScheduleMicrotask_act =
@@ -2477,13 +2478,13 @@ __DEV__ &&
24772478
null !== callbackNode &&
24782479
cancelCallback$1(callbackNode);
24792480
}
2480-
function scheduleImmediateTask(cb) {
2481+
function scheduleImmediateRootScheduleTask() {
24812482
null !== ReactSharedInternals.actQueue &&
24822483
ReactSharedInternals.actQueue.push(function () {
2483-
cb();
2484+
processRootScheduleInMicrotask();
24842485
return null;
24852486
});
2486-
scheduleCallback$3(ImmediatePriority, cb);
2487+
scheduleCallback$3(ImmediatePriority, processRootScheduleInImmediateTask);
24872488
}
24882489
function requestTransitionLane() {
24892490
0 === currentEventTransitionLane &&
@@ -11612,6 +11613,14 @@ __DEV__ &&
1161211613
flags & 2048 &&
1161311614
commitHookPassiveMountEffects(finishedWork, Passive | HasEffect);
1161411615
break;
11616+
case 1:
11617+
recursivelyTraversePassiveMountEffects(
11618+
finishedRoot,
11619+
finishedWork,
11620+
committedLanes,
11621+
committedTransitions
11622+
);
11623+
break;
1161511624
case 3:
1161611625
var prevEffectDuration = pushNestedEffectDurations();
1161711626
recursivelyTraversePassiveMountEffects(
@@ -13119,7 +13128,7 @@ __DEV__ &&
1311913128
}
1312013129
null !== ReactSharedInternals.actQueue
1312113130
? workLoopSync()
13122-
: workLoopConcurrent();
13131+
: workLoopConcurrentByScheduler();
1312313132
break;
1312413133
} catch (thrownValue$35) {
1312513134
handleThrow(root, thrownValue$35);
@@ -13144,7 +13153,7 @@ __DEV__ &&
1314413153
finishQueueingConcurrentUpdates();
1314513154
return workInProgressRootExitStatus;
1314613155
}
13147-
function workLoopConcurrent() {
13156+
function workLoopConcurrentByScheduler() {
1314813157
for (; null !== workInProgress && !shouldYield(); )
1314913158
performUnitOfWork(workInProgress);
1315013159
}
@@ -16894,10 +16903,10 @@ __DEV__ &&
1689416903
(function () {
1689516904
var internals = {
1689616905
bundleType: 1,
16897-
version: "19.1.0-www-classic-99471c02-20241220",
16906+
version: "19.1.0-www-classic-0de1233f-20250102",
1689816907
rendererPackageName: "react-art",
1689916908
currentDispatcherRef: ReactSharedInternals,
16900-
reconcilerVersion: "19.1.0-www-classic-99471c02-20241220"
16909+
reconcilerVersion: "19.1.0-www-classic-0de1233f-20250102"
1690116910
};
1690216911
internals.overrideHookState = overrideHookState;
1690316912
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16931,7 +16940,7 @@ __DEV__ &&
1693116940
exports.Shape = Shape;
1693216941
exports.Surface = Surface;
1693316942
exports.Text = Text;
16934-
exports.version = "19.1.0-www-classic-99471c02-20241220";
16943+
exports.version = "19.1.0-www-classic-0de1233f-20250102";
1693516944
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1693616945
"function" ===
1693716946
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,11 +2181,9 @@ __DEV__ &&
21812181
mightHavePendingSyncWork = !0;
21822182
null !== ReactSharedInternals.actQueue
21832183
? didScheduleMicrotask_act ||
2184-
((didScheduleMicrotask_act = !0),
2185-
scheduleImmediateTask(processRootScheduleInMicrotask))
2184+
((didScheduleMicrotask_act = !0), scheduleImmediateRootScheduleTask())
21862185
: didScheduleMicrotask ||
2187-
((didScheduleMicrotask = !0),
2188-
scheduleImmediateTask(processRootScheduleInMicrotask));
2186+
((didScheduleMicrotask = !0), scheduleImmediateRootScheduleTask());
21892187
enableDeferRootSchedulingToMicrotask ||
21902188
scheduleTaskForRootDuringMicrotask(root, now$1());
21912189
}
@@ -2231,6 +2229,9 @@ __DEV__ &&
22312229
isFlushingWork = !1;
22322230
}
22332231
}
2232+
function processRootScheduleInImmediateTask() {
2233+
processRootScheduleInMicrotask();
2234+
}
22342235
function processRootScheduleInMicrotask() {
22352236
mightHavePendingSyncWork =
22362237
didScheduleMicrotask_act =
@@ -2369,13 +2370,13 @@ __DEV__ &&
23692370
null !== callbackNode &&
23702371
cancelCallback$1(callbackNode);
23712372
}
2372-
function scheduleImmediateTask(cb) {
2373+
function scheduleImmediateRootScheduleTask() {
23732374
null !== ReactSharedInternals.actQueue &&
23742375
ReactSharedInternals.actQueue.push(function () {
2375-
cb();
2376+
processRootScheduleInMicrotask();
23762377
return null;
23772378
});
2378-
scheduleCallback$3(ImmediatePriority, cb);
2379+
scheduleCallback$3(ImmediatePriority, processRootScheduleInImmediateTask);
23792380
}
23802381
function requestTransitionLane() {
23812382
0 === currentEventTransitionLane &&
@@ -11416,6 +11417,14 @@ __DEV__ &&
1141611417
flags & 2048 &&
1141711418
commitHookPassiveMountEffects(finishedWork, Passive | HasEffect);
1141811419
break;
11420+
case 1:
11421+
recursivelyTraversePassiveMountEffects(
11422+
finishedRoot,
11423+
finishedWork,
11424+
committedLanes,
11425+
committedTransitions
11426+
);
11427+
break;
1141911428
case 3:
1142011429
var prevEffectDuration = pushNestedEffectDurations();
1142111430
recursivelyTraversePassiveMountEffects(
@@ -12923,7 +12932,7 @@ __DEV__ &&
1292312932
}
1292412933
null !== ReactSharedInternals.actQueue
1292512934
? workLoopSync()
12926-
: workLoopConcurrent();
12935+
: workLoopConcurrentByScheduler();
1292712936
break;
1292812937
} catch (thrownValue$35) {
1292912938
handleThrow(root, thrownValue$35);
@@ -12948,7 +12957,7 @@ __DEV__ &&
1294812957
finishQueueingConcurrentUpdates();
1294912958
return workInProgressRootExitStatus;
1295012959
}
12951-
function workLoopConcurrent() {
12960+
function workLoopConcurrentByScheduler() {
1295212961
for (; null !== workInProgress && !shouldYield(); )
1295312962
performUnitOfWork(workInProgress);
1295412963
}
@@ -16657,10 +16666,10 @@ __DEV__ &&
1665716666
(function () {
1665816667
var internals = {
1665916668
bundleType: 1,
16660-
version: "19.1.0-www-modern-99471c02-20241220",
16669+
version: "19.1.0-www-modern-0de1233f-20250102",
1666116670
rendererPackageName: "react-art",
1666216671
currentDispatcherRef: ReactSharedInternals,
16663-
reconcilerVersion: "19.1.0-www-modern-99471c02-20241220"
16672+
reconcilerVersion: "19.1.0-www-modern-0de1233f-20250102"
1666416673
};
1666516674
internals.overrideHookState = overrideHookState;
1666616675
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16694,7 +16703,7 @@ __DEV__ &&
1669416703
exports.Shape = Shape;
1669516704
exports.Surface = Surface;
1669616705
exports.Text = Text;
16697-
exports.version = "19.1.0-www-modern-99471c02-20241220";
16706+
exports.version = "19.1.0-www-modern-0de1233f-20250102";
1669816707
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1669916708
"function" ===
1670016709
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ function ensureRootIsScheduled(root) {
13481348
mightHavePendingSyncWork = !0;
13491349
didScheduleMicrotask ||
13501350
((didScheduleMicrotask = !0),
1351-
scheduleCallback$3(ImmediatePriority, processRootScheduleInMicrotask));
1351+
scheduleCallback$3(ImmediatePriority, processRootScheduleInImmediateTask));
13521352
enableDeferRootSchedulingToMicrotask ||
13531353
scheduleTaskForRootDuringMicrotask(root, now());
13541354
}
@@ -1395,7 +1395,7 @@ function flushSyncWorkAcrossRoots_impl(syncTransitionLanes, onlyLegacy) {
13951395
isFlushingWork = !1;
13961396
}
13971397
}
1398-
function processRootScheduleInMicrotask() {
1398+
function processRootScheduleInImmediateTask() {
13991399
mightHavePendingSyncWork = didScheduleMicrotask = !1;
14001400
0 !== currentEventTransitionLane && (currentEventTransitionLane = 0);
14011401
for (
@@ -8449,6 +8449,14 @@ function commitPassiveMountOnFiber(
84498449
);
84508450
flags & 2048 && commitHookEffectListMount(9, finishedWork);
84518451
break;
8452+
case 1:
8453+
recursivelyTraversePassiveMountEffects(
8454+
finishedRoot,
8455+
finishedWork,
8456+
committedLanes,
8457+
committedTransitions
8458+
);
8459+
break;
84528460
case 3:
84538461
recursivelyTraversePassiveMountEffects(
84548462
finishedRoot,
@@ -9739,7 +9747,7 @@ function renderRootConcurrent(root, lanes) {
97399747
throw Error(formatProdErrorMessage(462));
97409748
}
97419749
}
9742-
workLoopConcurrent();
9750+
workLoopConcurrentByScheduler();
97439751
break;
97449752
} catch (thrownValue$139) {
97459753
handleThrow(root, thrownValue$139);
@@ -9755,7 +9763,7 @@ function renderRootConcurrent(root, lanes) {
97559763
finishQueueingConcurrentUpdates();
97569764
return workInProgressRootExitStatus;
97579765
}
9758-
function workLoopConcurrent() {
9766+
function workLoopConcurrentByScheduler() {
97599767
for (; null !== workInProgress && !shouldYield(); )
97609768
performUnitOfWork(workInProgress);
97619769
}
@@ -10777,24 +10785,24 @@ var slice = Array.prototype.slice,
1077710785
};
1077810786
return Text;
1077910787
})(React.Component);
10780-
var internals$jscomp$inline_1501 = {
10788+
var internals$jscomp$inline_1507 = {
1078110789
bundleType: 0,
10782-
version: "19.1.0-www-classic-99471c02-20241220",
10790+
version: "19.1.0-www-classic-0de1233f-20250102",
1078310791
rendererPackageName: "react-art",
1078410792
currentDispatcherRef: ReactSharedInternals,
10785-
reconcilerVersion: "19.1.0-www-classic-99471c02-20241220"
10793+
reconcilerVersion: "19.1.0-www-classic-0de1233f-20250102"
1078610794
};
1078710795
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
10788-
var hook$jscomp$inline_1502 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
10796+
var hook$jscomp$inline_1508 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
1078910797
if (
10790-
!hook$jscomp$inline_1502.isDisabled &&
10791-
hook$jscomp$inline_1502.supportsFiber
10798+
!hook$jscomp$inline_1508.isDisabled &&
10799+
hook$jscomp$inline_1508.supportsFiber
1079210800
)
1079310801
try {
10794-
(rendererID = hook$jscomp$inline_1502.inject(
10795-
internals$jscomp$inline_1501
10802+
(rendererID = hook$jscomp$inline_1508.inject(
10803+
internals$jscomp$inline_1507
1079610804
)),
10797-
(injectedHook = hook$jscomp$inline_1502);
10805+
(injectedHook = hook$jscomp$inline_1508);
1079810806
} catch (err) {}
1079910807
}
1080010808
var Path = Mode$1.Path;
@@ -10808,4 +10816,4 @@ exports.RadialGradient = RadialGradient;
1080810816
exports.Shape = TYPES.SHAPE;
1080910817
exports.Surface = Surface;
1081010818
exports.Text = Text;
10811-
exports.version = "19.1.0-www-classic-99471c02-20241220";
10819+
exports.version = "19.1.0-www-classic-0de1233f-20250102";

0 commit comments

Comments
 (0)