Skip to content

Commit 6763e4e

Browse files
committed
Rerender through Lazy Components in dev if we were already aborting
1 parent 5c061dd commit 6763e4e

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
@@ -925,7 +925,11 @@ describe('ReactFlightDOMNode', () => {
925925

926926
if (__DEV__) {
927927
expect(ignoreListStack(ownerStack)).toBe(
928+
// eslint-disable-next-line react-internal/safe-string-coercion
928929
'' +
930+
(gate(flags => flags.enableAsyncDebugInfo)
931+
? '\n at SharedComponent (./ReactFlightDOMNode-test.js:791:7)'
932+
: '') +
929933
'\n at ServerComponent (file://./ReactFlightDOMNode-test.js:812:26)' +
930934
'\n at App (file://./ReactFlightDOMNode-test.js:829:25)',
931935
);
@@ -1518,12 +1522,12 @@ describe('ReactFlightDOMNode', () => {
15181522
'\n' +
15191523
' in Dynamic' +
15201524
(gate(flags => flags.enableAsyncDebugInfo)
1521-
? ' (file://ReactFlightDOMNode-test.js:1388:27)\n'
1525+
? ' (file://ReactFlightDOMNode-test.js:1392:27)\n'
15221526
: '\n') +
15231527
' in body\n' +
15241528
' in html\n' +
1525-
' in App (file://ReactFlightDOMNode-test.js:1405:25)\n' +
1526-
' in ClientRoot (ReactFlightDOMNode-test.js:1480:16)',
1529+
' in App (file://ReactFlightDOMNode-test.js:1409:25)\n' +
1530+
' in ClientRoot (ReactFlightDOMNode-test.js:1484:16)',
15271531
);
15281532
} else {
15291533
expect(
@@ -1532,7 +1536,7 @@ describe('ReactFlightDOMNode', () => {
15321536
'\n' +
15331537
' in body\n' +
15341538
' in html\n' +
1535-
' in ClientRoot (ReactFlightDOMNode-test.js:1480:16)',
1539+
' in ClientRoot (ReactFlightDOMNode-test.js:1484:16)',
15361540
);
15371541
}
15381542

@@ -1542,16 +1546,16 @@ describe('ReactFlightDOMNode', () => {
15421546
normalizeCodeLocInfo(ownerStack, {preserveLocation: true}),
15431547
).toBe(
15441548
'\n' +
1545-
' in Dynamic (file://ReactFlightDOMNode-test.js:1388:27)\n' +
1546-
' in App (file://ReactFlightDOMNode-test.js:1405:25)',
1549+
' in Dynamic (file://ReactFlightDOMNode-test.js:1392:27)\n' +
1550+
' in App (file://ReactFlightDOMNode-test.js:1409:25)',
15471551
);
15481552
} else {
15491553
expect(
15501554
normalizeCodeLocInfo(ownerStack, {preserveLocation: true}),
15511555
).toBe(
15521556
'' +
15531557
'\n' +
1554-
' in App (file://ReactFlightDOMNode-test.js:1405:25)',
1558+
' in App (file://ReactFlightDOMNode-test.js:1409:25)',
15551559
);
15561560
}
15571561
} 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)