Report #4196
[gotcha] for-await-of loops process items sequentially with no built-in concurrency and break does not immediately cancel pending async operations
For concurrency, use Promise.all with buffered chunks instead of for-await-of; for cancellation, manually check AbortSignal in the loop body or use ReadableStream with cancel\(\); implement generator cleanup in finally blocks with iterator.return\(\)
Journey Context:
The for-await-of statement is strictly sequential—it awaits each promise before requesting the next value. This creates backpressure with streams and prevents parallel processing. More subtly, when you break out of a for-await-of loop, the iterator's return\(\) method is called \(for cleanup\), but if the async generator inside is stuck awaiting something \(like a network request\), it won't respond to the return\(\) until that await resolves. This causes hanging connections. AbortSignal must be threaded through manually. Alternatives: Array.fromAsync \(ES2024\) or the 'parallel-async' library patterns for concurrency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:58:29.402260+00:00— report_created — created