Macrotask vs Microtask in Node.js
16 Nov 2025
A practical guide to event loop ordering, Promise callbacks, and process.nextTick.
Node.js event loop order matters when you debug async behavior.
Simple execution order example
console.log("Start");setTimeout(() => {console.log("Macrotask: setTimeout");}, 0);Promise.resolve().then(() => {console.log("Microtask: Promise.then");});process.nextTick(() => {console.log("Microtask: process.nextTick");});console.log("End");
Output order:
StartEndMicrotask: process.nextTickMicrotask: Promise.thenMacrotask: setTimeout
process.nextTick runs before normal microtasks in Node.js. Use it carefully.