Skip to content

Commit

Permalink
update error message to make more sense in node contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Jun 8, 2022
1 parent 06354fc commit cdeeb04
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ describe('ReactDOMFizzServer', () => {
errors,
[
[
'The server did not finish this Suspense boundary: signal is aborted without reason',
'The server did not finish this Suspense boundary: The render was aborted by the server without a reason.',
expectedDigest,
componentStack(['h1', 'Suspense', 'div', 'App']),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ describe('ReactDOMFizzServer', () => {
const result = await readResult(stream);
expect(result).toContain('Loading');

expect(errors).toEqual(['signal is aborted without reason']);
expect(errors).toEqual([
'The render was aborted by the server without a reason.',
]);
});

// @gate experimental
Expand Down Expand Up @@ -261,7 +263,9 @@ describe('ReactDOMFizzServer', () => {
const reader = stream.getReader();
reader.cancel();

expect(errors).toEqual(['signal is aborted without reason']);
expect(errors).toEqual([
'The render was aborted by the server without a reason.',
]);

hasLoaded = true;
resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ describe('ReactDOMFizzServer', () => {

expect(errors).toEqual([
// There are two boundaries that abort
'signal is aborted without reason',
'signal is aborted without reason',
'The render was aborted by the server without a reason.',
'The render was aborted by the server without a reason.',
]);
expect(output.error).toBe(undefined);
expect(output.result).toContain('Loading');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ describe('ReactDOMServerFB', () => {
const remaining = readResult(stream);
expect(remaining).toEqual('');

expect(errors).toEqual(['signal is aborted without reason']);
expect(errors).toEqual([
'The render was aborted by the server without a reason.',
]);
});
});
3 changes: 1 addition & 2 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,7 @@ function abortTask(task: Task, request: Request, reason: mixed): void {
boundary.forceClientRender = true;
let error =
reason === undefined
? // eslint-disable-next-line react-internal/prod-error-codes
new Error('signal is aborted without reason')
? new Error('The render was aborted by the server without a reason.')
: reason;
boundary.errorDigest = request.onError(error);
if (__DEV__) {
Expand Down
7 changes: 3 additions & 4 deletions scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@
"429": "ServerContext: %s already defined",
"430": "ServerContext can only have a value prop and children. Found: %s",
"431": "React elements are not allowed in ServerContext",
"432": "This Suspense boundary was aborted by the server.",
"432": "The render was aborted by the server without a reason.",
"433": "useId can only be used while React is rendering",
"434": "`dangerouslySetInnerHTML` does not make sense on <title>.",
"435": "The server did not finish this Suspense boundary. The server used \"%s\" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to \"%s\" which supports Suspense on the server"
}
"434": "`dangerouslySetInnerHTML` does not make sense on <title>."
}

0 comments on commit cdeeb04

Please sign in to comment.