@samitouri / QOS-React-2 / commits / fb324faf8a

Test case for stack overflow in ReactFizzServer (#25971)

SSR currently stack overflows when the component tree is extremely large

Tianyu Yao committed Jan 10, 2023 at 16:53 UTC fb324faf8a3da08212bcc5ea9e3a084dbfa80dad
1 file changed +22
packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js
+22
@@ -283,4 +283,26 @@ describe('ReactDOMFizzShellHydration', () => {
283 ]);
284 expect(container.textContent).toBe('New screen');
285 });
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 + });
308 });