From ebcb8306a53182af61aa9ecf50d4c58ad457f7f4 Mon Sep 17 00:00:00 2001 From: gpotter2 Date: Sat, 2 Jun 2018 22:21:50 +0200 Subject: [PATCH] process: make getActive{Handles,Requests} official Make process.getActiveHandles() and make.getActiveRequests() official and deprecate the older process._getActiveHandles() and process._getActiveRequests(). Also add a small documentation --- doc/api/deprecations.md | 9 ++++++ doc/api/process.md | 29 +++++++++++++++++++ lib/internal/bootstrap/node.js | 14 +++++++++ src/node.cc | 4 +-- .../parallel/test-process-getactivehandles.js | 2 +- test/pseudo-tty/ref_keeps_node_running.js | 2 +- test/pummel/test-net-connect-econnrefused.js | 4 +-- 7 files changed, 58 insertions(+), 6 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 0b4d4986e16e64..b65bf0c72ffe6a 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1005,6 +1005,15 @@ accepted by the legacy `url.parse()` API. The mentioned APIs now use the WHATWG URL parser that requires strictly valid URLs. Passing an invalid URL is deprecated and support will be removed in the future. + +### DEP0110: _getActiveHandles and _getActiveRequests + +Type: Runtime + +As `process.getActiveHandles()` and `process.getActiveRequests()` are +officially supported and documented, their previous names are now deprecated, +and will be removed in the future. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array diff --git a/doc/api/process.md b/doc/api/process.md index e6612278b6bc4a..d6b50ee5febeed 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1053,6 +1053,35 @@ a code. Specifying a code to [`process.exit(code)`][`process.exit()`] will override any previous setting of `process.exitCode`. +## process.getActiveHandles() + + +* Returns: {Array} + +Returns an array containing all handles that are preventing the Node.js process +from exiting. Be aware that the returned handles may not always correspond to +the user-created handles, but instead to an internal one. + +```js +console.log(`Active handles: ${util.inspect(process.getActiveHandles())}`); +``` + +## process.getActiveRequests() + + +* Returns: {Array} + +Returns an array containing all requests that are preventing the Node.js process +from exiting. + +```js +console.log(`Active requests: ${util.inspect(process.getActiveRequests())}`); +``` + ## process.getegid()