Skip to content

Commit d814027

Browse files
committed
Rerender through Lazy Components in dev if we were already aborting
1 parent f0476c9 commit d814027

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,11 @@ describe('ReactFlightDOMNode', () => {
928928

929929
if (__DEV__) {
930930
expect(ignoreListStack(ownerStack)).toBe(
931+
// eslint-disable-next-line react-internal/safe-string-coercion
931932
'' +
933+
(gate(flags => flags.enableAsyncDebugInfo)
934+
? '\n at SharedComponent (./ReactFlightDOMNode-test.js:794:7)'
935+
: '') +
932936
'\n at ServerComponent (file://./ReactFlightDOMNode-test.js:815:26)' +
933937
'\n at App (file://./ReactFlightDOMNode-test.js:832:25)',
934938
);
@@ -1521,12 +1525,12 @@ describe('ReactFlightDOMNode', () => {
15211525
'\n' +
15221526
' in Dynamic' +
15231527
(gate(flags => flags.enableAsyncDebugInfo)
1524-
? ' (file://ReactFlightDOMNode-test.js:1391:27)\n'
1528+
? ' (file://ReactFlightDOMNode-test.js:1395:27)\n'
15251529
: '\n') +
15261530
' in body\n' +
15271531
' in html\n' +
1528-
' in App (file://ReactFlightDOMNode-test.js:1408:25)\n' +
1529-
' in ClientRoot (ReactFlightDOMNode-test.js:1483:16)',
1532+
' in App (file://ReactFlightDOMNode-test.js:1412:25)\n' +
1533+
' in ClientRoot (ReactFlightDOMNode-test.js:1487:16)',
15301534
);
15311535
} else {
15321536
expect(
@@ -1535,7 +1539,7 @@ describe('ReactFlightDOMNode', () => {
15351539
'\n' +
15361540
' in body\n' +
15371541
' in html\n' +
1538-
' in ClientRoot (ReactFlightDOMNode-test.js:1483:16)',
1542+
' in ClientRoot (ReactFlightDOMNode-test.js:1487:16)',
15391543
);
15401544
}
15411545

@@ -1545,16 +1549,16 @@ describe('ReactFlightDOMNode', () => {
15451549
normalizeCodeLocInfo(ownerStack, {preserveLocation: true}),
15461550
).toBe(
15471551
'\n' +
1548-
' in Dynamic (file://ReactFlightDOMNode-test.js:1391:27)\n' +
1549-
' in App (file://ReactFlightDOMNode-test.js:1408:25)',
1552+
' in Dynamic (file://ReactFlightDOMNode-test.js:1395:27)\n' +
1553+
' in App (file://ReactFlightDOMNode-test.js:1412:25)',
15501554
);
15511555
} else {
15521556
expect(
15531557
normalizeCodeLocInfo(ownerStack, {preserveLocation: true}),
15541558
).toBe(
15551559
'' +
15561560
'\n' +
1557-
' in App (file://ReactFlightDOMNode-test.js:1408:25)',
1561+
' in App (file://ReactFlightDOMNode-test.js:1412:25)',
15581562
);
15591563
}
15601564
} else {

packages/react-server/src/ReactFizzServer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2802,14 +2802,23 @@ function renderLazyComponent(
28022802
ref: any,
28032803
): void {
28042804
let Component;
2805+
let previouslyAbortingDEV;
28052806
if (__DEV__) {
2807+
previouslyAbortingDEV = request.status === ABORTING;
28062808
Component = callLazyInitInDEV(lazyComponent);
28072809
} else {
28082810
const payload = lazyComponent._payload;
28092811
const init = lazyComponent._init;
28102812
Component = init(payload);
28112813
}
2812-
if (request.status === ABORTING) {
2814+
if (
2815+
request.status === ABORTING &&
2816+
// If we already started rendering the Lazy Componentn in an aborting state
2817+
// and reach this point, the lazy was already resolved.
2818+
// We don't bail here again since this is most likely a discarded rerender
2819+
// to get the stack where we suspended in dev.
2820+
(!__DEV__ || !previouslyAbortingDEV)
2821+
) {
28132822
// eslint-disable-next-line no-throw-literal
28142823
throw null;
28152824
}

0 commit comments

Comments
 (0)