Skip to content
Tutorials Center
My learning

Topics

Node.js Reference ยท process

Node.js process.abort() method

Reference for process.abort() in Node.js: end the process at once with SIGABRT, no exit handlers and an optional core file, and how it differs from process.exit().

process.abort() ends the Node.js process immediately by raising the SIGABRT signal. No exit event is emitted, no cleanup handler runs, and anything your code was still going to write is lost. If the operating system is set up to write core files, a core dump is produced, which a debugger can open to inspect the state of the process at that moment.

It is a tool for post-mortem debugging and for fail-fast code in situations where continuing would be dangerous. For normal shutdowns use process.exit() or, better, let the event loop empty on its own.

NODE
// Dangerous: kills the process with SIGABRT
process.abort();

Try it

Really aborting would end the run with no output (and the sandbox would spend its time on the core file), so the first example only shows what an abort would skip, and the second compares the clean exit paths you should normally use.

Node.js What an abort would skip

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Node.js Clean exit paths for comparison

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Syntax

NODE
process.abort(): never

The method takes no arguments and never returns.

Effect: the process receives SIGABRT. On POSIX systems the parent sees the signal name instead of an exit code, and a shell reports status 134 (128 plus signal number 6). On Windows the process also ends with a non-zero code.

Edge cases:

  • A core file is written only if the system allows it. On Linux the shell limit (ulimit -c) and the core_pattern setting decide. Without them the process still ends but leaves nothing behind.
  • In a worker thread process.abort() is not available and throws ERR_WORKER_UNSUPPORTED_OPERATION.

Usage notes

  • No cleanup. Listeners for exit and beforeExit, pending timers and stream finish callbacks do not run. Data not yet written is lost.
  • Core dumps can be large and contain secrets from memory, such as keys and tokens. Treat them like sensitive files.
  • Alternative: diagnostic reports. process.report writes a readable JSON report without killing the process, and the flag --abort-on-uncaught-exception aborts only on an uncaught error, giving a core dump at the exact place of the throw.
  • Rarely right in production code. Prefer a graceful path: stop accepting work, finish what is in flight, then call process.exit() or set process.exitCode.
  • Supervisors such as systemd or Kubernetes see a crash by signal and restart the service, which is useful when you want a restart plus a core file for later study.
  • Compared with process.kill(process.pid, 'SIGABRT'): the result is similar, but abort() does not go through Node's signal handling.