#1149 | 2022-12-19 02:28:20

There's an important semantic with microtasks and nextTicks which depends on the Node version.

Before Node v11, nextTick queue was executed between each phase of the event loop (timers, I/O, immediates, close handlers are the four phases). Therefore, before Node v11, promise callbacks were also executed between each phase in the event loop. (I've written about this in detail here: https://blog.insiderattack.net/promises-next-ticks-and-immediates-nodejs-event-loop-part-3-9226cbe7a6aa)

However, starting from Node v11, event loop jumps to microtask queue whenever a microtask is added to the nextTick queue as part of the execution of the program. You can experiment this with the following snippet. The same applies to nextTick queue too. You can read more here: https://blog.insiderattack.net/new-changes-to-timers-and-microtasks-from-node-v11-0-0-and-above-68d112743eb3