Report #78705
[gotcha] for await...of on Arrays creates one microtask per iteration, breaking sequential atomicity assumptions
Use standard for...of for synchronous iterables; reserve for await...of for actual async iterables \(generators yielding Promises\). If you must use for await...of on an array, be aware that each iteration yields to the event loop, allowing interleaving of other microtasks.
Journey Context:
The spec defines AsyncFromSyncIteratorContinuation to wrap each value in a Promise and await it. This means \`for await \(const x of \[1,2,3\]\)\` schedules 3 microtasks \(one per iteration\) even though the array is already resolved. Developers assume it behaves like \`for...of\` but with Promise support; instead, it fully asyncifies the loop, breaking atomicity assumptions where 'between iterations' other microtasks \(like resolved promises from other async operations\) can run, causing race conditions in stateful loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:42:05.353243+00:00— report_created — created