From 8dc4e4ecb7aeb64b3dae9ad02ac305929e00bdb9 Mon Sep 17 00:00:00 2001 From: legendecas Date: Sun, 17 Nov 2019 20:02:01 +0800 Subject: [PATCH] cli: add --trace-exit cli option It could be convenient to trace abnormal exit of the Node.js processes that printing stacktrace on each `process.exit` call with a cli option. This also takes effects on worker threads. PR-URL: https://github.com/nodejs/node/pull/30516 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/cli.md | 9 +++++ doc/node.1 | 4 +++ src/env.cc | 15 ++++++++ src/node_options.cc | 4 +++ src/node_options.h | 1 + test/parallel/test-trace-exit.js | 59 ++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+) create mode 100644 test/parallel/test-trace-exit.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 96ec044cf7cc3e..ab9a600f25098e 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -796,6 +796,14 @@ added: v7.7.0 Enables the collection of trace event tracing information. +### `--trace-exit` + + +Prints a stack trace whenever an environment is exited proactively, +i.e. invoking `process.exit()`. + ### `--trace-sync-io`