Skip to content

Commit

Permalink
Add a wrapper error around recovered concurrent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Apr 3, 2024
1 parent dc9bd13 commit be80438
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,8 @@ describe('ReactDOMFizzServer', () => {
'B',

// Log the error
'onRecoverableError: Oops!',
'onRecoverableError: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.',
'Cause: Oops!',
]);

// UI looks normal
Expand Down
9 changes: 7 additions & 2 deletions packages/react-reconciler/src/ReactFiberThrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,12 @@ function throwException(
// Otherwise, fall through to the error path.
}

const errorInfo = createCapturedValueAtFiber(value, sourceFiber);
queueConcurrentError(errorInfo);
const wrapperError = new Error(
'There was an error during concurrent rendering but React was able to recover by ' +
'instead synchronously rendering the entire root.',
{cause: value},
);
queueConcurrentError(createCapturedValueAtFiber(wrapperError, sourceFiber));
renderDidError();

// We didn't find a boundary that could handle this type of exception. Start
Expand All @@ -614,6 +618,7 @@ function throwException(
return true;
}

const errorInfo = createCapturedValueAtFiber(value, sourceFiber);
let workInProgress: Fiber = returnFiber;
do {
switch (workInProgress.tag) {
Expand Down

0 comments on commit be80438

Please sign in to comment.