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,