I help maintain the process.nextTick implementation used in browserify. A simplified explanation of how it works is as follows

var timeout = setTimeout(cleanupFunc); var i = -1; while (++i < tasks.length) { tasks[i].run(); } clearTimeout(timeout);

basically we set a timeout for a cleanup function which we clear after we run all the tasks, the idea is that the only way for this to be able to run is if there is an exception thrown in the task that is run, otherwise nothing can stop the loop from completing synchronously and clearing the timeout.

This is actually a mistaken assumption, can anyone identify why?

Simple, if somebody calls window.open inside of a task then firefox will pause execution of function while it waits for the window to open and spin the event loop while it waits causing the cleanup function to be called in the middle of the other function.

This would seem to be a bug in firefox but I wonder how many other async libraries you can break in firefox by opening a new window in the callback.