[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
H
Hendrik Liebau committed
cf993fb457417e0f20535b1fd42c3f45df966583
Parent: c137dd6
Committed by GitHub <noreply@github.com>
on 2/4/2026, 6:43:23 PM