From 3bbace7735b94ed76c509643a984e4863fee7f1e Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Tue, 26 Feb 2019 12:01:03 -0800 Subject: [PATCH 1/4] domain: allow concurrent user-land impl Currently, only one domain-lke implementation (the core domain one) can be used to handle uncaught exceptions or unhandled error events. This PR aims at making it possible for different domain-like user-land implementations to be used concurrently (including with the core domain impl) so that the state of the core domain module (doc deprecated) does not prevent users of domains from having a well-maintained domain-like facility. Ref: https://github.com/nodejs/node/issues/23348 Co-authored-by: Rich Trott --- doc/api/errors.md | 42 ++++++++------ doc/api/repl.md | 29 ++++------ lib/domain.js | 35 ++++-------- lib/events.js | 56 +++++++++++++++---- lib/internal/errors.js | 9 --- ...ad-after-set-uncaught-exception-capture.js | 11 ---- ...t-uncaught-exception-capture-after-load.js | 28 ---------- 7 files changed, 90 insertions(+), 120 deletions(-) delete mode 100644 test/parallel/test-domain-set-uncaught-exception-capture-after-load.js diff --git a/doc/api/errors.md b/doc/api/errors.md index f0d78854703a41..ed6e4385ba43f6 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1014,23 +1014,6 @@ ongoing asynchronous operations. `c-ares` failed to set the DNS server. - -### `ERR_DOMAIN_CALLBACK_NOT_AVAILABLE` - -The `domain` module was not usable since it could not establish the required -error handling hooks, because -[`process.setUncaughtExceptionCaptureCallback()`][] had been called at an -earlier point in time. - - -### `ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE` - -[`process.setUncaughtExceptionCaptureCallback()`][] could not be called -because the `domain` module has been loaded at an earlier point in time. - -The stack trace is extended to include the point in time at which the -`domain` module had been loaded. - ### `ERR_ENCODING_INVALID_ENCODED_DATA` @@ -2473,6 +2456,31 @@ The UTF-16 encoding was used with [`hash.digest()`][]. While the causing the method to return a string rather than a `Buffer`, the UTF-16 encoding (e.g. `ucs` or `utf16le`) is not supported. + +### `ERR_DOMAIN_CALLBACK_NOT_AVAILABLE` + + +The `domain` module was not usable since it could not establish the required +error handling hooks, because +[`process.setUncaughtExceptionCaptureCallback()`][] had been called at an +earlier point in time. + + +### `ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE` + + +[`process.setUncaughtExceptionCaptureCallback()`][] could not be called +because the `domain` module has been loaded at an earlier point in time. + +The stack trace is extended to include the point in time at which the +`domain` module had been loaded. + ### `ERR_HTTP2_FRAME_ERROR`