setImmediate(func)


#1

What’s the current standards track / implementation thinking on this? With the momentum that’s come up behind Promises, it seems like something like this must have been added under the hood in Firefox and Chrome. (And, of course, Node/io.js are requiring it over process.nextTick() “in the next version”.)


#2

We never got enough traction in the webperf group to standardize it. An old draft is at http://w3c.github.io/web-performance/specs/setImmediate/Overview.html but we never went beyond that. Look at the thread at https://lists.w3.org/Archives/Public/public-web-perf/2013Aug/0025.html .


#3

What I don’t get is why nobody in those threads suggested treating an infinitely recursive setImmediate() loop the same way as browsers treat while(true){} now: namely, letting it run for a few seconds (without throttling), then halting the thread’s execution while the user is prompted that the tab appears to be over-working (albeit not frozen), and asked if they want to kill it. This would discourage devs from abusing setImmediate where they should be using requestAnimationFrame or something throttled like setTimeout(0), while still allowing good-actors to use it uninhibited.


#4

Is there somewhere I can suggest this be revisited? What’s involved in posting to es-discuss?


#5

you might want to check out http://lists.w3.org/Archives/Public/public-web-perf/2015Jun/0099.html and https://docs.google.com/document/d/1ZgYOBi_39-N6AbjL99qesiDagaSTbpN0R6CrSVK8NE4/edit