mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
The event loop slept to its next timer with nanosleep. macOS applies the timer slack of the thread's QoS class to nanosleep: a 5 ms sleep takes about 38 ms at utility QoS and 180 ms at background QoS, where launchd services such as CI jobs run. Timers then fired out of order against Node, whose libuv loop waits with a kevent timeout that keeps its deadline at every QoS. On macOS the loop now sleeps with a kevent timeout on a kqueue with no events, shared by every thread's loop. Intervals also re-arm from the time their callback started, as Node's listOnTimeout does, instead of from the clock after the callback: a callback that takes 30 ms of a 50 ms interval keeps the ticks 50 ms apart, and one slower than the interval makes the next tick due on the next turn. interval-slow-callback.ts checks both against Node.