Node.js Core · 8 min read · Intermediate
Event Loop & Async Concurrency
Master microtasks (Promises), timers, and running independent async tasks concurrently with Promise.all().
What you'll learn
- Predict execution order across synchronous code, Promise microtasks, and setTimeout
- Run independent async I/O calls concurrently using Promise.all()
- Handle partial failures cleanly with Promise.allSettled()
In Node.js, Promise callbacks (microtasks) always drain immediately after the current call stack finishes, before the next timer (setTimeout) callback runs.
Fill-in-the-Blank Exercise
Concurrent Async Calls
Run fetchUsers() and fetchCourses() in parallel with Promise.all.
const [users, courses] = Promise.([
fetchUsers(),
fetchCourses(),
]);Live Code Lab (Node.js 20)
Node.jsevent_loop.js
Expected OutputClick “Run Live” to compile with Node.js 20
1. sync start 2. sync end 3. promise microtask 4. timer macrotask
Check Your Understanding
Score: 0 / 1
1. Which runs first after synchronous code finishes: a resolved Promise .then() or a setTimeout(fn, 0)?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.