What is the difference between message queue and macrotask queue? Is it the same thing?
On Nodejs documentation here it says:
When setTimeout() is called, the Browser or Node.js starts the timer. Once the timer expires, in this case immediately as we put 0 as the timeout, the callback function is put in the Message Queue.
While, in this section, it says:
A setTimeout, setImmediate callback is added to macrotask queue
So, does message queue and macrotask queue is the same thing?
It refers to the same thing here. One could say that "message queue" is a more general term, as in "the microtask queue and the macrotask queue are both message queues".
If I am reading this right, it seems the "Message Queue" is a general term that is implemented using a few different queues.
In this section they explain:
A process.nextTick callback is added to process.nextTick queue. A Promise.then() callback is added to promises microtask queue. A setTimeout, setImmediate callback is added to macrotask queue.
Looks like the macrotask, microtask, etc. are specific parts of the implementation and have different attributes.
For example, execution order:
Event loop executes tasks in process.nextTick queue first, and then executes promises microtask queue, and then executes macrotask queue.
Found another easy explanation here.