From d8ce9a0e234660d268f60fb55b156aebfaf29310 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 3e7ccc1133c858..37065087e17f53 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -784,6 +784,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`