Skip to content

Commit bcc746d

Browse files
committed
Add a wrapper error around recovered concurrent errors
1 parent dc9bd13 commit bcc746d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,8 @@ describe('ReactDOMFizzServer', () => {
32973297
'B',
32983298

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

33033304
// UI looks normal

packages/react-reconciler/src/ReactFiberThrow.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,12 @@ function throwException(
600600
// Otherwise, fall through to the error path.
601601
}
602602

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

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

621+
const errorInfo = createCapturedValueAtFiber(value, sourceFiber);
617622
let workInProgress: Fiber = returnFiber;
618623
do {
619624
switch (workInProgress.tag) {

scripts/error-codes/codes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,6 @@
504504
"516": "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.",
505505
"517": "Symbols cannot be passed to a Server Function without a temporary reference set. Pass a TemporaryReferenceSet to the options.%s",
506506
"518": "Saw multiple hydration diff roots in a pass. This is a bug in React.",
507-
"519": "Hydration Mismatch Exception: This is not a real error, and should not leak into userspace. If you're seeing this, it's likely a bug in React."
507+
"519": "Hydration Mismatch Exception: This is not a real error, and should not leak into userspace. If you're seeing this, it's likely a bug in React.",
508+
"520": "There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root."
508509
}

0 commit comments

Comments
 (0)