Event Loop Phases

Each phase of the Event Loop is responsible for different types of operations. There are 44 such phases:

  1. Timers
  2. I/O callbacks
  3. setImmediate
  4. Close callbacks

Each of these phases have their separate Callback Queue.

Event Loop Phases execution strategy It starts by looking at the timer queue and checks if there are any functions that are available to execute i.e., functions for timers that have completed. It then moves on to I/O callback. And after that, it checks for any setImmediate functions. In the end, it checks for Close Callbacks i.e., callbacks when a file or DB connection is closed. It then starts again from the top (hence the name 'Event Loop').


Backlinks