mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
When multiple setTimeout timers are scheduled to fire at the same time (same millisecond), they should all execute before any setImmediate callbacks that were scheduled by those timer callbacks. This matches Node.js behavior. The bug occurred because the timer readiness check in `drainTimers()` used full nanosecond precision, while the timer heap ordering uses millisecond-truncated precision for JavaScript timers. This meant two timers scheduled within the same millisecond could have different nanosecond values, causing one to be considered "in the future" even though both should fire together. The fix aligns the timer readiness check with the heap ordering by truncating to millisecond precision for JavaScript timers. Fixes #26508 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>