From 64cb43a2b6370705536a2d530152cf85f00ad923 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Tue, 13 Sep 2022 08:29:10 +0000 Subject: [PATCH] node-api: add deprecation code of uncaught exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deprecation should reference a valid deprecation code. PR-URL: https://github.com/nodejs/node/pull/44624 Refs: https://github.com/nodejs/node/pull/36510 Reviewed-By: Tobias Nießen Reviewed-By: Michael Dawson --- doc/api/deprecations.md | 22 ++++++++++++++++++++++ src/node_api.cc | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 33168decdb796a..72303a10f2a783 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3217,12 +3217,34 @@ details. These groups might be removed in future versions of Node.js. Applications that rely on these groups should evaluate using stronger MODP groups instead. +### DEP0168: Unhandled exception in Node-API callbacks + + + +Type: Runtime. + +The implicit suppression of uncaught exceptions in Node-API callbacks is now +deprecated. + +Set the flag [`--force-node-api-uncaught-exceptions-policy`][] to force Node.js +to emit an [`'uncaughtException'`][] event if the exception is not handled in +Node-API callbacks. + [Legacy URL API]: url.md#legacy-url-api [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 [WHATWG URL API]: url.md#the-whatwg-url-api [`"exports"` or `"main"` entry]: packages.md#main-entry-point-export +[`'uncaughtException'`]: process.md#event-uncaughtexception +[`--force-node-api-uncaught-exceptions-policy`]: cli.md#--force-node-api-uncaught-exceptions-policy [`--pending-deprecation`]: cli.md#--pending-deprecation [`--throw-deprecation`]: cli.md#--throw-deprecation [`--trace-atomics-wait`]: cli.md#--trace-atomics-wait diff --git a/src/node_api.cc b/src/node_api.cc index 922d6ffac1927b..48b94a7c12873c 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -90,7 +90,7 @@ void node_napi_env__::CallbackIntoModule(T&& call) { "Uncaught N-API callback exception detected, please run node " "with option --force-node-api-uncaught-exceptions-policy=true" "to handle those exceptions properly.", - "DEP0XXX"); + "DEP0168"); return; } // If there was an unhandled exception in the complete callback,