From eff4265b3e3469803898167e0157f8aafdac2844 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 11 Sep 2017 12:27:42 +0200 Subject: [PATCH] promises: add --abort-on-unhandled-rejection Support creating core dumps of unhandled promise rejections on POSIX systems by keeping `fork()`s of the process alive until it is known whether they are handled synchronously or not. --- doc/api/cli.md | 16 ++ doc/node.1 | 11 ++ lib/internal/process/promises.js | 17 ++ src/env.h | 2 + src/node.cc | 155 +++++++++++++++++++ test/abort/test-abort-unhandled-rejection.js | 30 ++++ 6 files changed, 231 insertions(+) create mode 100644 test/abort/test-abort-unhandled-rejection.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 4b2f78d94a55f1..bf415fc9b962ad 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -183,6 +183,21 @@ added: v0.10 Aborting instead of exiting causes a core file to be generated for post-mortem analysis using a debugger (such as `lldb`, `gdb`, and `mdb`). +### `--abort-on-unhandled-rejection` + + +Aborting instead of exiting causes a core file to be generated for post-mortem +analysis using a debugger (such as `lldb`, `gdb`, and `mdb`). + +This option only affects `Promise` rejections. It is only available on POSIX +systems. It is implemented by keeping `fork()`ed copies of the process alive +until it is known whether the `Promise` is handled within the same event loop +iteration or is left unhandled. +This makes unhandled rejections a significantly more complex operation, +which may have performance implications. + ### `--trace-warnings`