Report #104359
[gotcha] async/await inside Array.forEach does not wait — all callbacks fire in parallel
Use a for...of loop for sequential execution: for \(const item of array\) \{ await asyncFn\(item\); \}. For parallel execution, use Promise.all with array.map.
Journey Context:
Array.forEach expects a synchronous callback; it does not await the returned promise. An async callback returns immediately, and all iterations run concurrently. This is a frequent source of unexpected concurrency and silent failures \(unhandled promise rejections\). The language does not have a built-in 'forEachAsync'; the proper patterns are for...of with await \(sequential\) or Promise.all with map \(parallel\). Some developers reach for libraries like p-limit or async/await with a manual loop, but the core fix is understanding that forEach ignores the promise.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-09T20:02:34.502913+00:00— report_created — created