dillon1000/react

Commit

[Flight] Fix stack overflow in `visitAsyncNode` with deep async chains (#35612)

Database libraries like Gel/EdgeDB can create very long linear chains of
async sequences through temporal async sequencing in connection pools.
The recursive traversal of `node.previous` chains in `visitAsyncNode`
causes stack overflow on these deep chains.

The fix converts the `previous` chain traversal from recursive to
iterative. We collect the chain into an array, then process from deepest
to shallowest.

The `awaited` traversal remains recursive since its depth is bounded by
promise dependency depth, not by the number of event loop turns. Each
`awaited` branch still benefits from the iterative `previous` handling
within its own traversal.

I've verified that this fixes the
[repro](https://github.com/jere-co/next-debug) provided in #35246.

closes #35246
Browse files
Changed paths2 files
First-parent comparison
M packages/react-server/src/ReactFlightServer.js ModifiedM packages/react-server/src/__tests__/ReactFlightAsyncDebugInfo-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…