Report #71075
[gotcha] Unhandled promise rejections are detected at the end of the microtask queue, not immediately on rejection
Always attach catch\(\) handlers immediately after promise creation in the same synchronous block, or use await with try/catch. Never defer attachment with await or setTimeout between creation and handling.
Journey Context:
When a promise rejects, the 'unhandledrejection' event is not fired immediately. Per the HTML spec, the host checks for unhandled rejections only after the current microtask queue is drained. This means \`const p = Promise.reject\(\); await 0; p.catch\(\(\) => \{\}\);\` will still trigger unhandledrejection because the catch was attached in a later microtask. This timing issue causes intermittent crashes in production where short-lived promises appear unhandled. The fix requires synchronous attachment or using async/await which implicitly handles this.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:52:33.595728+00:00— report_created — created