Skip to content

Commit 48023e9

Browse files
committed
Simplify abort error handling
The way dev generates errors from the hash, message, and stack parts we can use errorHash like a message if we do not also send a message. This means we can unify the implementation for both dev and prod and get the expected outcomes on the client regardless of which mode they are running in. I noticed this because there was an edge case before where if you ran the server in dev mode and the client in prod mode you would not see this error message at all.
1 parent db2ba1d commit 48023e9

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,16 +1492,9 @@ function abortTask(task: Task): void {
14921492

14931493
if (!boundary.forceClientRender) {
14941494
boundary.forceClientRender = true;
1495-
if (__DEV__) {
1496-
// In DEV error messages are sent to the client and since this is not being handled
1497-
// by onError there is no error hash to send.
1498-
boundary.errorMessage =
1499-
'This Suspense boundary was aborted by the server';
1500-
} else {
1501-
// In Prod only error hashes are sent to the client. Even though this is not a hash
1502-
// it will get bubbled up to the user the way we expect it to which is why it goes here
1503-
boundary.errorHash = 'This Suspense boundary was aborted by the server';
1504-
}
1495+
// Technically not a hash since there is no error to pass to onError. However it will be handled
1496+
// the way we want in both dev and prod modes on the client if we report it here as a hash
1497+
boundary.errorHash = 'This Suspense boundary was aborted by the server';
15051498
if (boundary.parentFlushed) {
15061499
request.clientRenderedBoundaries.push(boundary);
15071500
}

0 commit comments

Comments
 (0)