Shouldn't timers be specified?

Brandon Benvie brandon at
Sat Jan 21 19:26:24 PST 2012

I just finished answering this question on StackOverflow and it got me
thinking about the obvious: timers are not specified yet are central to a
vast swath of JavaScript code. Timers in Node.js have a significantly
higher resolution than what is found in browsers: `setTimeout(fn, 1)` will,
in fact, execute in 1 millisecond (assuming the system isn't taxed to the
point of being unresponsive). Browsers have collectively implemented a
floor at around 15ms. Code that works fine in a browser can very well melt
the computer if run in Node. For reference, here's the answer I wrote on

It doesn't have a minimum delay and this is actually a compatibility issue
between browsers and node. Timers are completely unspecified and node
implements them simply due to how fundamental they've been in JavaScript's
history and how irreplaceable they are otherwise.

Node uses libuv which a cross-platform abstraction layer for lower level
system things like file-system, networking stuff, etc. One of those things
is timers, which Node provides a minimal wrapper around. At the libuv
level, the timers used are the system-specific high precision timers. In
Windows, for example, this is implemented using QueryPerformanceFrequency
 and FileTimeToSystemTime which provides resolution measured in nanoseconds.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list