-
Notifications
You must be signed in to change notification settings - Fork 284
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 stability issues? #1318
Comments
I think the problem is that it is not safe to execute N-API calls in the Looking at the documentation I believe we need to make this much clearer. it does say that [in] execute: The native function which should be called to execute the logic asynchronously. The given function is called from a worker pool thread and can execute in parallel with the main event loop thread. . @gabrielschulhof do you have any other comments to add? |
Ah, that's a detail I didn't really take note of, nor knew what it meant (it not being safe). So - I would simply put the resolving of the deferred in |
We really shouldn't have passed the `napi_env` into the execute callback,
because it lends the expression that the full gamut of APIs which accept a
`napi_env` is available – where in fact it is not.
…On Tue, Jun 5, 2018 at 5:26 PM, Andreas Opferkuch ***@***.***> wrote:
Ah, that's a detail I didn't really take not of, nor knew what it meant
(it not being safe).
So - I would simply put the resolving of the Promise in complete instead
and everything should be good, right? (I've just tried that and
unfortunately, it doesn't work - while what I had was unstable, at least
the .then() was run whenever execution was successful. But if I resolve the
Promise in complete, the process exists before then() runs.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1318 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA7k0VWQCAvJxiMOSHBxlpFIvkiT6p48ks5t5veDgaJpZM4UZWUI>
.
|
@gabrielschulhof I'll create a PR to clarify in the docs at least to start. @s-h-a-d-o-w moving to |
I've narrowed down the problem to the call to |
You may now be running into nodejs/node#20966 (comment) |
Ah, cool - well... you know... good to know. 😉 Thanks for all your help! |
Clarify that calls to N-API should be avoided in the 'execute' callback. Refs: nodejs/help#1318
Clarify that calls to N-API should be avoided in the 'execute' callback. PR-URL: #21217 Refs: nodejs/help#1318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Clarify that calls to N-API should be avoided in the 'execute' callback. PR-URL: #21217 Refs: nodejs/help#1318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
https://github.com/s-h-a-d-o-w/napi-test
My repo that I linked to above contains a very simple example based around Promises. Considering the fact that N-API in node 10 is called "Stable", I would've expected that at least once everything was compiled successfully, my code would run consistently. Unfortunately, it doesn't and I wonder whether it's N-API's fault or mine (Maybe some problem with how I handle the async work? That's the only thing I can think of that might cause random problems):
Expected output:
Errors that I get about 10% of the time (One time, execution even froze, I had to interrupt it. And sometimes, there is no output at all...):
The text was updated successfully, but these errors were encountered: