Skip to content

Commit

Permalink
Log and show error overlay for commit phase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jun 22, 2021
1 parent 568dc35 commit 12267f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,14 @@ export function captureCommitPhaseError(
nearestMountedAncestor: Fiber | null,
error: mixed,
) {
if (__DEV__) {
// Commit phase doesn't use invokeGuardedCallback anymore due to perf.
// However, we still want to print the message and make it fire onerror.
invokeGuardedCallback(null, () => {
throw error;
});
}

if (sourceFiber.tag === HostRoot) {
// Error was thrown at the root. There is no parent, so the root
// itself should capture it.
Expand Down
8 changes: 8 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,14 @@ export function captureCommitPhaseError(
nearestMountedAncestor: Fiber | null,
error: mixed,
) {
if (__DEV__) {
// Commit phase doesn't use invokeGuardedCallback anymore due to perf.
// However, we still want to print the message and make it fire onerror.
invokeGuardedCallback(null, () => {
throw error;
});
}

if (sourceFiber.tag === HostRoot) {
// Error was thrown at the root. There is no parent, so the root
// itself should capture it.
Expand Down

0 comments on commit 12267f2

Please sign in to comment.