Skip to content

Commit 8b596cd

Browse files
committed
fix bug in legacy dom server preventing some errors from propagating to client
1 parent 7f69424 commit 8b596cd

File tree

9 files changed

+44
-46
lines changed

9 files changed

+44
-46
lines changed

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ describe('ReactDOMFizzServer', () => {
465465
loggedErrors.push(x);
466466
return 'Hash of (' + x.message + ')';
467467
}
468-
const expectedHash = onError(theError);
468+
const expectedDigest = onError(theError);
469469
loggedErrors.length = 0;
470470

471471
await act(async () => {
@@ -504,14 +504,14 @@ describe('ReactDOMFizzServer', () => {
504504
[
505505
[
506506
theError.message,
507-
expectedHash,
507+
expectedDigest,
508508
componentStack(['Lazy', 'Suspense', 'div', 'App']),
509509
],
510510
],
511511
[
512512
[
513513
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
514-
expectedHash,
514+
expectedDigest,
515515
],
516516
],
517517
);
@@ -568,7 +568,7 @@ describe('ReactDOMFizzServer', () => {
568568
loggedErrors.push(x);
569569
return 'hash of (' + x.message + ')';
570570
}
571-
const expectedHash = onError(theError);
571+
const expectedDigest = onError(theError);
572572
loggedErrors.length = 0;
573573

574574
function App({isClient}) {
@@ -624,14 +624,14 @@ describe('ReactDOMFizzServer', () => {
624624
[
625625
[
626626
theError.message,
627-
expectedHash,
627+
expectedDigest,
628628
componentStack(['Suspense', 'div', 'App']),
629629
],
630630
],
631631
[
632632
[
633633
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
634-
expectedHash,
634+
expectedDigest,
635635
],
636636
],
637637
);
@@ -675,7 +675,7 @@ describe('ReactDOMFizzServer', () => {
675675
loggedErrors.push(x);
676676
return 'hash(' + x.message + ')';
677677
}
678-
const expectedHash = onError(theError);
678+
const expectedDigest = onError(theError);
679679
loggedErrors.length = 0;
680680

681681
await act(async () => {
@@ -706,14 +706,14 @@ describe('ReactDOMFizzServer', () => {
706706
[
707707
[
708708
theError.message,
709-
expectedHash,
709+
expectedDigest,
710710
componentStack(['Erroring', 'Suspense', 'div', 'App']),
711711
],
712712
],
713713
[
714714
[
715715
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
716-
expectedHash,
716+
expectedDigest,
717717
],
718718
],
719719
);
@@ -744,7 +744,7 @@ describe('ReactDOMFizzServer', () => {
744744
loggedErrors.push(x);
745745
return 'hash(' + x.message + ')';
746746
}
747-
const expectedHash = onError(theError);
747+
const expectedDigest = onError(theError);
748748
loggedErrors.length = 0;
749749

750750
await act(async () => {
@@ -785,14 +785,14 @@ describe('ReactDOMFizzServer', () => {
785785
[
786786
[
787787
theError.message,
788-
expectedHash,
788+
expectedDigest,
789789
componentStack(['Lazy', 'Suspense', 'div', 'App']),
790790
],
791791
],
792792
[
793793
[
794794
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
795-
expectedHash,
795+
expectedDigest,
796796
],
797797
],
798798
);
@@ -1071,10 +1071,10 @@ describe('ReactDOMFizzServer', () => {
10711071
}
10721072

10731073
const loggedErrors = [];
1074-
const expectedHash = 'Hash for Abort';
1074+
const expectedDigest = 'Hash for Abort';
10751075
function onError(error) {
10761076
loggedErrors.push(error);
1077-
return expectedHash;
1077+
return expectedDigest;
10781078
}
10791079

10801080
let controls;
@@ -1106,11 +1106,11 @@ describe('ReactDOMFizzServer', () => {
11061106
expect(Scheduler).toFlushAndYield([]);
11071107
expectErrors(
11081108
errors,
1109-
[['This Suspense boundary was aborted by the server', expectedHash]],
1109+
[['This Suspense boundary was aborted by the server.', expectedDigest]],
11101110
[
11111111
[
11121112
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
1113-
expectedHash,
1113+
expectedDigest,
11141114
],
11151115
],
11161116
);
@@ -1777,7 +1777,7 @@ describe('ReactDOMFizzServer', () => {
17771777
loggedErrors.push(x);
17781778
return `hash of (${x.message})`;
17791779
}
1780-
const expectedHash = onError(theError);
1780+
const expectedDigest = onError(theError);
17811781
loggedErrors.length = 0;
17821782

17831783
let controls;
@@ -1834,7 +1834,7 @@ describe('ReactDOMFizzServer', () => {
18341834
[
18351835
[
18361836
theError.message,
1837-
expectedHash,
1837+
expectedDigest,
18381838
componentStack([
18391839
'AsyncText',
18401840
'h1',
@@ -1848,7 +1848,7 @@ describe('ReactDOMFizzServer', () => {
18481848
[
18491849
[
18501850
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
1851-
expectedHash,
1851+
expectedDigest,
18521852
],
18531853
],
18541854
);
@@ -3180,7 +3180,7 @@ describe('ReactDOMFizzServer', () => {
31803180
loggedErrors.push(x);
31813181
return x.message.replace('bad message', 'bad hash');
31823182
}
3183-
const expectedHash = onError(theError);
3183+
const expectedDigest = onError(theError);
31843184
loggedErrors.length = 0;
31853185

31863186
await act(async () => {
@@ -3206,14 +3206,14 @@ describe('ReactDOMFizzServer', () => {
32063206
[
32073207
[
32083208
theError.message,
3209-
expectedHash,
3209+
expectedDigest,
32103210
componentStack(['Erroring', 'Suspense', 'div', 'App']),
32113211
],
32123212
],
32133213
[
32143214
[
32153215
'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.',
3216-
expectedHash,
3216+
expectedDigest,
32173217
],
32183218
],
32193219
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ describe('ReactDOMFizzServer', () => {
215215
expect(result).toContain('Loading');
216216

217217
expect(errors).toEqual([
218-
'This Suspense boundary was aborted by the server',
218+
'This Suspense boundary was aborted by the server.',
219219
]);
220220
});
221221

@@ -256,7 +256,7 @@ describe('ReactDOMFizzServer', () => {
256256
reader.cancel();
257257

258258
expect(errors).toEqual([
259-
'This Suspense boundary was aborted by the server',
259+
'This Suspense boundary was aborted by the server.',
260260
]);
261261

262262
hasLoaded = true;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ describe('ReactDOMFizzServer', () => {
226226
expect(output.result).toBe('');
227227
expect(reportedErrors).toEqual([
228228
theError.message,
229-
'This Suspense boundary was aborted by the server',
229+
'This Suspense boundary was aborted by the server.',
230230
]);
231231
expect(reportedShellErrors).toEqual([theError]);
232232
});
@@ -322,7 +322,7 @@ describe('ReactDOMFizzServer', () => {
322322
await completed;
323323

324324
expect(errors).toEqual([
325-
'This Suspense boundary was aborted by the server',
325+
'This Suspense boundary was aborted by the server.',
326326
]);
327327
expect(output.error).toBe(undefined);
328328
expect(output.result).toContain('Loading');
@@ -365,8 +365,8 @@ describe('ReactDOMFizzServer', () => {
365365

366366
expect(errors).toEqual([
367367
// There are two boundaries that abort
368-
'This Suspense boundary was aborted by the server',
369-
'This Suspense boundary was aborted by the server',
368+
'This Suspense boundary was aborted by the server.',
369+
'This Suspense boundary was aborted by the server.',
370370
]);
371371
expect(output.error).toBe(undefined);
372372
expect(output.result).toContain('Loading');
@@ -603,7 +603,7 @@ describe('ReactDOMFizzServer', () => {
603603
await completed;
604604

605605
expect(errors).toEqual([
606-
'This Suspense boundary was aborted by the server',
606+
'This Suspense boundary was aborted by the server.',
607607
]);
608608
expect(rendered).toBe(false);
609609
expect(isComplete).toBe(true);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ describe('ReactDOMServerHydration', () => {
815815
}
816816
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
817817
Array [
818-
"Caught [The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.]",
818+
"Caught [This Suspense boundary was aborted by the server.]",
819819
]
820820
`);
821821
});
@@ -840,7 +840,7 @@ describe('ReactDOMServerHydration', () => {
840840
}
841841
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
842842
Array [
843-
"Caught [The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.]",
843+
"Caught [This Suspense boundary was aborted by the server.]",
844844
]
845845
`);
846846
});

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,8 +1669,7 @@ describe('ReactDOMServerPartialHydration', () => {
16691669
},
16701670
});
16711671
expect(Scheduler).toFlushAndYield([
1672-
'The server could not finish this Suspense boundary, likely due to ' +
1673-
'an error during server rendering. Switched to client rendering.',
1672+
'This Suspense boundary was aborted by the server.',
16741673
]);
16751674
jest.runAllTimers();
16761675

@@ -1731,8 +1730,7 @@ describe('ReactDOMServerPartialHydration', () => {
17311730
},
17321731
});
17331732
expect(Scheduler).toFlushAndYield([
1734-
'The server could not finish this Suspense boundary, likely due to ' +
1735-
'an error during server rendering. Switched to client rendering.',
1733+
'This Suspense boundary was aborted by the server.',
17361734
]);
17371735
// This will have exceeded the suspended time so we should timeout.
17381736
jest.advanceTimersByTime(500);
@@ -1798,8 +1796,7 @@ describe('ReactDOMServerPartialHydration', () => {
17981796
},
17991797
});
18001798
expect(Scheduler).toFlushAndYield([
1801-
'The server could not finish this Suspense boundary, likely due to ' +
1802-
'an error during server rendering. Switched to client rendering.',
1799+
'This Suspense boundary was aborted by the server.',
18031800
]);
18041801
// This will have exceeded the suspended time so we should timeout.
18051802
jest.advanceTimersByTime(500);
@@ -2116,8 +2113,7 @@ describe('ReactDOMServerPartialHydration', () => {
21162113

21172114
suspend = true;
21182115
expect(Scheduler).toFlushAndYield([
2119-
'The server could not finish this Suspense boundary, likely due to ' +
2120-
'an error during server rendering. Switched to client rendering.',
2116+
'This Suspense boundary was aborted by the server.',
21212117
]);
21222118

21232119
// We haven't hydrated the second child but the placeholder is still in the list.
@@ -2179,8 +2175,7 @@ describe('ReactDOMServerPartialHydration', () => {
21792175
},
21802176
});
21812177
expect(Scheduler).toFlushAndYield([
2182-
'The server could not finish this Suspense boundary, likely due to ' +
2183-
'an error during server rendering. Switched to client rendering.',
2178+
'This Suspense boundary was aborted by the server.',
21842179
]);
21852180
jest.runAllTimers();
21862181

packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export function writeStartClientRenderedSuspenseBoundary(
150150
responseState: ResponseState,
151151
// flushing these error arguments are not currently supported in this legacy streaming format.
152152
errorDigest: ?string,
153-
errorMessage?: string,
154-
errorComponentStack?: string,
153+
errorMessage: ?string,
154+
errorComponentStack: ?string,
155155
): boolean {
156156
if (responseState.generateStaticMarkup) {
157157
// A client rendered boundary is done and doesn't need a representation in the HTML
@@ -161,6 +161,9 @@ export function writeStartClientRenderedSuspenseBoundary(
161161
return writeStartClientRenderedSuspenseBoundaryImpl(
162162
destination,
163163
responseState,
164+
errorDigest,
165+
errorMessage,
166+
errorComponentStack,
164167
);
165168
}
166169
export function writeEndCompletedSuspenseBoundary(

packages/react-server-dom-relay/src/__tests__/ReactDOMServerFB-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ describe('ReactDOMServerFB', () => {
192192
expect(remaining).toEqual('');
193193

194194
expect(errors).toEqual([
195-
'This Suspense boundary was aborted by the server',
195+
'This Suspense boundary was aborted by the server.',
196196
]);
197197
});
198198
});

packages/react-server/src/ReactFizzServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ function abortTask(task: Task): void {
15541554
if (!boundary.forceClientRender) {
15551555
boundary.forceClientRender = true;
15561556
const error = new Error(
1557-
'This Suspense boundary was aborted by the server',
1557+
'This Suspense boundary was aborted by the server.',
15581558
);
15591559
boundary.errorDigest = request.onError(error);
15601560
if (__DEV__) {

scripts/error-codes/codes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,6 @@
417417
"429": "ServerContext: %s already defined",
418418
"430": "ServerContext can only have a value prop and children. Found: %s",
419419
"431": "React elements are not allowed in ServerContext",
420-
"432": "This Suspense boundary was aborted by the server",
420+
"432": "This Suspense boundary was aborted by the server.",
421421
"433": "useId can only be used while React is rendering"
422422
}

0 commit comments

Comments
 (0)