Skip to content

Commit 12267f2

Browse files
committed
Log and show error overlay for commit phase errors
1 parent 568dc35 commit 12267f2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,14 @@ export function captureCommitPhaseError(
21962196
nearestMountedAncestor: Fiber | null,
21972197
error: mixed,
21982198
) {
2199+
if (__DEV__) {
2200+
// Commit phase doesn't use invokeGuardedCallback anymore due to perf.
2201+
// However, we still want to print the message and make it fire onerror.
2202+
invokeGuardedCallback(null, () => {
2203+
throw error;
2204+
});
2205+
}
2206+
21992207
if (sourceFiber.tag === HostRoot) {
22002208
// Error was thrown at the root. There is no parent, so the root
22012209
// itself should capture it.

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,14 @@ export function captureCommitPhaseError(
21962196
nearestMountedAncestor: Fiber | null,
21972197
error: mixed,
21982198
) {
2199+
if (__DEV__) {
2200+
// Commit phase doesn't use invokeGuardedCallback anymore due to perf.
2201+
// However, we still want to print the message and make it fire onerror.
2202+
invokeGuardedCallback(null, () => {
2203+
throw error;
2204+
});
2205+
}
2206+
21992207
if (sourceFiber.tag === HostRoot) {
22002208
// Error was thrown at the root. There is no parent, so the root
22012209
// itself should capture it.

0 commit comments

Comments
 (0)