Skip to content

Commit fb324fa

Browse files
authored
Test case for stack overflow in ReactFizzServer (#25971)
SSR currently stack overflows when the component tree is extremely large
1 parent a48e54f commit fb324fa

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,26 @@ describe('ReactDOMFizzShellHydration', () => {
283283
]);
284284
expect(container.textContent).toBe('New screen');
285285
});
286+
287+
test('TODO: A large component stack causes SSR to stack overflow', async () => {
288+
spyOnDevAndProd(console, 'error');
289+
290+
function NestedComponent({depth}: {depth: number}) {
291+
if (depth <= 0) {
292+
return <AsyncText text="Shell" />;
293+
}
294+
return <NestedComponent depth={depth - 1} />;
295+
}
296+
297+
// Server render
298+
await serverAct(async () => {
299+
ReactDOMFizzServer.renderToPipeableStream(
300+
<NestedComponent depth={3000} />,
301+
);
302+
});
303+
expect(console.error).toHaveBeenCalledTimes(1);
304+
expect(console.error.calls.argsFor(0)[0].toString()).toBe(
305+
'RangeError: Maximum call stack size exceeded',
306+
);
307+
});
286308
});

0 commit comments

Comments
 (0)