From 48023e9f62c4172b0f23f918e413701202b0e54e Mon Sep 17 00:00:00 2001 From: Josh Story Date: Fri, 13 May 2022 13:49:09 -0700 Subject: [PATCH] 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. --- packages/react-server/src/ReactFizzServer.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 97aa52e8538b..4cb163d8fe38 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -1492,16 +1492,9 @@ function abortTask(task: Task): void { if (!boundary.forceClientRender) { boundary.forceClientRender = true; - if (__DEV__) { - // In DEV error messages are sent to the client and since this is not being handled - // by onError there is no error hash to send. - boundary.errorMessage = - 'This Suspense boundary was aborted by the server'; - } else { - // In Prod only error hashes are sent to the client. Even though this is not a hash - // it will get bubbled up to the user the way we expect it to which is why it goes here - boundary.errorHash = 'This Suspense boundary was aborted by the server'; - } + // Technically not a hash since there is no error to pass to onError. However it will be handled + // the way we want in both dev and prod modes on the client if we report it here as a hash + boundary.errorHash = 'This Suspense boundary was aborted by the server'; if (boundary.parentFlushed) { request.clientRenderedBoundaries.push(boundary); }