Skip to content

process: add process.exitSoon()

Rodrigo Muino Tomonari requested to merge github/fork/jasnell/exit-timeout into master
Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

process

Description of change

Updated: adds process.exitSoon([code[, timeout]]) and 'exitingSoon' event to process. Allows exitingSoon handlers to defer exit until they are ready. Timer is optional.

When set, an internal timer will be set that will exit the process at the given timeout. In the meantime, the registered listeners for process.on('exitingSoon') will be invoked and passed a callback to be called when the handler is ready for the process to exit. The process will exit either when the internal timer fires or all the callbacks are called, whichever comes first.

This is an attempt to deal more intelligently with resource cleanup and async op completion on exit

Docs / test case included

Refs: https://github.com/nodejs/node/issues/6456

Merge request reports

Loading