beforeExit and exit events

Process events: beforeExit fires when the event loop has run out of work and may schedule more, while exit fires just before the process ends and allows only synchronous code.

In more detail

beforeExit is not emitted when process.exit() is called or on an uncaught exception. Inside exit handlers, asynchronous work such as a network request never completes because the loop has already stopped.

Related terms

Taught in

References