Report #95478
[gotcha] for await...of on synchronous Arrays processes items sequentially with microtask overhead, not in parallel
Use \`Promise.all\(arr.map\(async ...\)\)\` for concurrent async operations. Reserve \`for await...of\` for true async iterables or when strict sequential execution with backpressure is explicitly required.
Journey Context:
Developers often conflate \`for await...of\` with 'async iteration' generally, thinking it parallelizes like \`Promise.all\`. When fed a sync iterable \(like an Array\), the spec mandates that it creates an AsyncFromSyncIterator, which yields each value wrapped in a Promise, then awaits it, introducing a microtick per item. This results in sequential execution with overhead. If the array contains promises, \`for await...of\` resolves them one by one. This is correct for backpressure \(e.g., streaming\), but disastrous for 'fetch 100 URLs'. The alternative \`for \(const p of arr\) await p\` is similar. For true parallelism, \`Promise.all\` is the only correct tool.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:50:16.146594+00:00— report_created — created