-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass exceptions to JS that are thrown by JS functions in an async context #36402
Labels
node-api
Issues and PRs related to the Node-API.
Comments
/cc @nodejs/n-api |
@legendecas just submitted a PR to uncaught exceptions so he will take a look at this one and comment. |
I think this is what #36510 intended to fix. |
4 tasks
guangwong
pushed a commit
to noslate-project/node
that referenced
this issue
Oct 10, 2022
PR-URL: nodejs/node#36510 Fixes: nodejs/node#36402 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
When invoking an async function, the only way to notify JS of exceptions thrown by the function is by checking the result of every async JS function call and invoking
napi_fatal_exception
if needed. It would be great ifnapi_fatal_exception
was called automatically when exceptions propagate out of an async function.Describe the solution you'd like
I would like the invoker of
napi_threadsafe_function_call_js
(which is passed intonapi_create_threadsafe_function
) to detect when exceptions bubble out of the async callback and callnapi_fatal_exception(env, error);
Currently, thenapi_threadsafe_function_call_js
is invoked bynode_napi_env::CallIntoModule
which runs the codewhere
handle_exception
by default callsv8::Isolate::ThrowException
which does nothing in an async context.Describe alternatives you've considered
Perhaps the real problem here is that
v8::Isolate::ThrowException
does not propagate exceptions to JS when invoked in an async context? Perhaps this is a bug with v8?The text was updated successfully, but these errors were encountered: