-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
N-API request: Ability to report fatal exception resulting from callbacks that are thrown outside the regular JS call stack #15371
Comments
There is a |
Unfortunately it doesn't seem like it would fit my needs. Having a similar wrapper for |
What happens when you use |
It seems the stack trace and abort is the same:
But looking at that |
|
#14697 solves a lot of problems, but the process uncaught exception handler is still not called by |
I have found a solution/workaround/hack. The following patch solves my problems
I really don't know whether or not this makes sense, but hopefully it is useful for someone more knowledgeable about the internals. |
@rolftimmermans I think that's probably the correct fix. |
Not really … (The origin of the reported issue here is that So, ugh. This is not trivial. The most natural solution might just be to parametrize After that, maybe we could expose something that leads to the same code paths that Node’s own native uncaught exception handler also calls. I am not sure, but just adding a function that throws some input parameter as an exception inside a verbose (And while I’m writing this: I’m not understanding myself rn why |
The exception thrown in I don't understand how a verbose It looks like we just need to add a |
Ooh, I missed that
As far as I understand it, the difference is that a verbose (Which can also be in the form of an |
Just ran into this same issue, anyway I can help get this fixed? |
Working woth the test case in nodejs/node-addon-api#235, I'm thinking I'll add
|
Believe this was closed by #19337, please re-open if you believe that is not the case. |
I am attempting to (re)write a node module to use N-API, but there is an issue that I cannot see a workaround for.
I want to use
uv_poll_t
/uv_poll_init_socket
etc. to set up socket polling to handle socket events in the native addon. In the native callback there is a code path that executes a JS callback. Looks something like this:Unfortunately any exception thrown in the JS callback will crash the process. Instead I want to report a fatal exception to Node, so that it can be delegated to the
uncaughtException
event ofprocess
.Essentially, I want to use this code, identical to what is used in the async callback:
node/src/node_api.cc
Lines 3296 to 3301 in a10856a
But there seems to be no way to do this. Even if I include
v8.h
andnode.h
I cannot convert the exception from N-API back to a v8 exception so I can callnode::FatalException
.Ideally I'd like either:
Ability to call
node::FatalException()
via a supported addition to N-API (so that I can cause anuncaughtException
event to be emitted); orAbility to use
uv_poll_t
/uv_poll_init_socket
etc via a supported addition to N-API, similar tonapi_create_async_work
etc.The text was updated successfully, but these errors were encountered: