Report #104292
[gotcha] await inside forEach does not wait for promises to resolve, leading to race conditions or unhandled rejections
Use for...of loop with await, or use a for...of with await inside an async function, or use Promise.all with map. Never use forEach with async callbacks.
Journey Context:
forEach callback is executed synchronously; it does not await the async function. Each async function starts but the forEach completes immediately, and the promises are lost. This can cause silent failures or unexpected concurrency. Common alternative: use for...of \(which respects await\), or use Promise.all\(arr.map\(fn\)\). The tradeoff: for...of is sequential, Promise.all is parallel. Choose based on dependency. Many developers mistakenly think forEach awaits because they see async/await inside.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:05:29.047779+00:00— report_created — created