From e9de692b3e1e7ae28ecad537eb595429c1312bad Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 24 Dec 2024 18:05:19 -0800 Subject: [PATCH] fixup! TSFN fatal uncaught exception handling --- doc/api/n-api.md | 4 ++-- src/node_api.cc | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 69c0b51318ffe8..3ba991dc11789d 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -1748,7 +1748,7 @@ will not be freed. This can be avoided by calling **Change History:** -* Experimental (`NAPI_EXPERIMENTAL` is defined): +* Version 10 (`NAPI_VERSION` is defined as `10` or higher): References can be created for all value types. The new supported value types do not support weak reference semantic and the values of these types @@ -6527,7 +6527,7 @@ napi_create_threadsafe_function(napi_env env, **Change History:** -* Experimental (`NAPI_EXPERIMENTAL` is defined): +* Version 10 (`NAPI_VERSION` is defined as `10` or higher): Uncaught exceptions thrown in `call_js_cb` are handled with the [`'uncaughtException'`][] event, instead of being ignored. diff --git a/src/node_api.cc b/src/node_api.cc index 42fa05290a0842..1638d096969826 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -93,11 +93,11 @@ void node_napi_env__::CallbackIntoModule(T&& call) { return; } node::Environment* node_env = env->node_env(); - // If the module api version is less than NAPI_VERSION_EXPERIMENTAL, - // and the option --force-node-api-uncaught-exceptions-policy is not - // specified, emit a warning about the uncaught exception instead of - // triggering uncaught exception event. - if (env->module_api_version < NAPI_VERSION_EXPERIMENTAL && + // If the module api version is less than 10, and the option + // --force-node-api-uncaught-exceptions-policy is not specified, emit a + // warning about the uncaught exception instead of triggering the uncaught + // exception event. + if (env->module_api_version < 10 && !node_env->options()->force_node_api_uncaught_exceptions_policy && !enforceUncaughtExceptionPolicy) { ProcessEmitDeprecationWarning(