I had a weird timing bug in my app that came from switching from Bluebird to native promises. I fixed it, but am left with this oddity: Native promises seem to wiggle their way in between nextTick
and setImmediate
-- how? And is this supposed to happen? Where are promises supposed to go with regard to these?
~function(){
setTimeout (console.log.bind(console, 'timeout A'));
process.nextTick (console.log.bind(console, 'nextTick A'));
setImmediate (console.log.bind(console, 'setImmediate A'));
Promise.resolve().then(console.log.bind(console, 'promise'));
process.nextTick (console.log.bind(console, 'nextTick B'));
setImmediate (console.log.bind(console, 'setImmediate B'));
setTimeout (console.log.bind(console, 'timeout B'));
}();
Native yields:
nextTick A
nextTick B
promise undefined
setImmediate A
setImmediate B
timeout A
timeout B
Bluebird yields:
nextTick A
nextTick B
setImmediate A
promise undefined
setImmediate B
timeout A
timeout B