close callbacks phase
The last phase of each event loop turn, which runs close handlers, such as a socket's close event after socket.destroy().
In more detail
Keeping teardown in its own phase means resources are released after the other work of the turn. Once it finishes, the loop checks whether any active handles remain before starting another turn.
Related terms
- event loop phase — One of the six stages the Node.js event loop visits in order on every turn: timers, pending callbacks, idle/prepare, poll, check and close callbacks.
- libuv handle — A libuv object representing a long-lived resource such as a timer, socket or server; while active ones remain, the event loop keeps the process alive.
- stream.destroy() — The method that closes a stream straight away, releasing its resources and optionally reporting an error.
Taught in
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services