Skip to content

Commit b2a0edf

Browse files
committed
Rerender through Lazy Components in dev if we were already aborting
1 parent 334cdfb commit b2a0edf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,9 @@ describe('ReactFlightDOMNode', () => {
927927
if (__DEV__) {
928928
expect(ignoreListStack(ownerStack)).toBe(
929929
'' +
930+
// The concrete location may change as this test is updated.
931+
// Just make sure they still point at React.use(p2)
932+
'\n at SharedComponent (./ReactFlightDOMNode-test.js:794:7)' +
930933
'\n at ServerComponent (file://./ReactFlightDOMNode-test.js:815:26)' +
931934
'\n at App (file://./ReactFlightDOMNode-test.js:832:25)',
932935
);

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)