You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Detect unsettled top-level await and exit like Node (exit 13 + warning) #33283
Split out from #14951, which was closed for its CPU-spin half (fixed by #32014: condition-gated drive loops now ref the event loop and park instead of busy-spinning).
The other half remains: when a module's top-level await never settles and nothing else refs the event loop, Node prints a warning and exits 13:
$ node -e 'await new Promise(() => {})'Warning: Detected unsettled top-level await at [eval]:1await new Promise(() => {})^
$ echo$?13
Bun's wait_for_promise refs the loop for the duration of the wait, so it waits for any pending unref'd timer and otherwise parks indefinitely rather than exiting. Verified against Node 26.3/26.4.
Implementing this means detecting "the module promise is pending and nothing other than this driver refs the loop", emitting the warning at the awaiting source location, and exiting 13. Two tests in test/js/web/timers/timers-unref-idle-loop.test.ts carry TODOs pointing here and assert today's divergent behavior (exit 0, no warning); they should be flipped as part of the fix.
Related: #31501 (closed as a duplicate of #14951).
✅ Reproduced: an unsettled top-level await in the entry module (e.g. await new Promise(() => {})) spins at ~100% CPU and never exits; Node warns and exits 13.
Fix (warn + exit 13, scoped to the main entry) → #33286
Activity
github-actions commentedon Jul 2, 2026
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
robobun commentedon Jul 2, 2026
✅ Reproduced: an unsettled top-level await in the entry module (e.g.
await new Promise(() => {})) spins at ~100% CPU and never exits; Node warns and exits 13.Fix (warn + exit 13, scoped to the main entry) → #33286
ReadableStreamfromnode:stream/web#32528 as a duplicate of this issuenode:http: do not give a request the socket of a failed connection (#…