Skip to content
skillbld
Node.js · 14-day planAll days
Day 6 of 14 30 min

Node runs your JavaScript on a single thread, yet handles thousands of connections at once. Learn how the event loop, the call stack, the task queues and libuv's thread pool fit together, the order of nextTick, promises, timers and setImmediate, and how to avoid blocking the loop.

By the end of today you can

  • Explain how one thread can handle many requests at once
  • Describe the phases of the event loop
  • Predict the order of sync code, nextTick, promises, timers and setImmediate
  • Recognise code that blocks the event loop
  • Keep the loop responsive by splitting work or using worker threads

What's inside

  • 4 sections
  • 4 diagrams and mind maps
  • 4 code examples you can run
  • 5-question quiz
  1. 1One thread, lots of waiting
  2. 2The order things run
  3. 3The phases of the loop
  4. 4Don't block the event loop

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free

Keep going

Day 6: The Event Loop · Node.js · SkillBld