Test case for stack overflow in ReactFizzServer (#25971)

SSR currently stack overflows when the component tree is extremely large
This commit is contained in:
Tianyu Yao 2023-01-10 16:53:16 -08:00 committed by GitHub
parent a48e54f2b7
commit fb324faf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -283,4 +283,26 @@ describe('ReactDOMFizzShellHydration', () => {
]);
expect(container.textContent).toBe('New screen');
});
test('TODO: A large component stack causes SSR to stack overflow', async () => {
spyOnDevAndProd(console, 'error');
function NestedComponent({depth}: {depth: number}) {
if (depth <= 0) {
return <AsyncText text="Shell" />;
}
return <NestedComponent depth={depth - 1} />;
}
// Server render
await serverAct(async () => {
ReactDOMFizzServer.renderToPipeableStream(
<NestedComponent depth={3000} />,
);
});
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0].toString()).toBe(
'RangeError: Maximum call stack size exceeded',
);
});
});