8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9b752e commit eb29266Copy full SHA for eb29266
src/node_api.cc
@@ -2910,11 +2910,15 @@ napi_status napi_make_callback(napi_env env,
2910
isolate, v8recv, v8func, argc,
2911
reinterpret_cast<v8::Local<v8::Value>*>(const_cast<napi_value*>(argv)),
2912
*node_async_context);
2913
- CHECK_MAYBE_EMPTY(env, callback_result, napi_generic_failure);
2914
2915
- if (result != nullptr) {
2916
- *result = v8impl::JsValueFromV8LocalValue(
2917
- callback_result.ToLocalChecked());
+ if (try_catch.HasCaught()) {
+ return napi_set_last_error(env, napi_pending_exception);
+ } else {
+ CHECK_MAYBE_EMPTY(env, callback_result, napi_generic_failure);
2918
+ if (result != nullptr) {
2919
+ *result = v8impl::JsValueFromV8LocalValue(
2920
+ callback_result.ToLocalChecked());
2921
+ }
2922
}
2923
2924
return GET_RETURN_STATUS(env);
test/addons-napi/test_make_callback_recurse/binding.cc
@@ -12,9 +12,22 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) {
12
napi_value recv = args[0];
13
napi_value func = args[1];
14
15
- napi_make_callback(env, nullptr /* async_context */,
+ napi_status status = napi_make_callback(env, nullptr /* async_context */,
16
recv, func, 0 /* argc */, nullptr /* argv */, nullptr /* result */);
17
18
+ bool isExceptionPending;
19
+ NAPI_CALL(env, napi_is_exception_pending(env, &isExceptionPending));
20
+ if (isExceptionPending && !(status == napi_pending_exception)) {
21
+ // if there is an exception pending we don't expect any
22
+ // other error
23
+ napi_value pending_error;
24
+ status = napi_get_and_clear_last_exception(env, &pending_error);
25
+ NAPI_CALL(env,
26
+ napi_throw_error((env),
27
+ nullptr,
28
+ "error when only pending exception expected"));
29
30
+
31
return recv;
32
33