-
Notifications
You must be signed in to change notification settings - Fork 465
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
Add support for callback scopes #223
Comments
I'll take this issue. |
@romandev thanks ! |
Sorry for delayed work. I was on a vacation until last week. I'm looking into this issue now but need your confirmation. Shouldn't we need to implement the async hooks wrapper(e.g. napi_async_init) first before implementing this feature? I found the related comments in the PR[1] but didn't find any follow-up change in C++ wrapper side. Do you have a plan to make a followup change? Otherwise, I'm available. [1] #140 |
@romandev that is a very good point. If you can work on adding async hooks wrapper that would be great :) |
Is there any way to use callback scopes from a napi_async_work? Normally an async worker would create it's Javascript values from within the scope of the complete_callback, but there's an issue right now around error handling - there's no way to return a Javascript error from the execute_callback, just a string or manual workarounds. Noticed the comments here mentioning an async hooks wrapper for napi_async_init; might be another use-case worth thinking about. |
What's the story for new features like this when running precompiled libraries on older versions of Node? Would this library provide a backport for older Node.js versions or would a library depending on nodejs/node#18089 have to target Node.js 9.6.0+ only? |
@rolftimmermans, in general not all new features would be backported to earlier versions. However, I am hoping that we will backport what becomes non-experimental in 10.x to 8.x (and we'll have to look at 6.x) in order to accelerate initial adoption. The complication is that not all versions of 8.x will have the feature, is that something you can work around by requiring Node.js 8.X or higher ? |
@ebickle I have a todo to look at the error issue with complete_callback, but I'm going to be travelling a fair amount over the next 3 weeks so I'm not quite sure how/when I'm going to get to it. |
@mhdawson I guess it is possible to depend on a certain 8.X version, but it's less than ideal. The feature was introduced in 9.6 it seems, so not sure if the specific 8.X version would matter? |
The issue is that if/when we backport, it will go into the latest 8.X release. So it would be available in 8.Y or later and 9.6 and later. |
I see. It's probably less than ideal because a lot of distros have already shipped with Node 8. So people who can easily install a future 8.X version can probably also install 9 or 10. |
The following code is how I implemented a C++ wrapper in my code currently. Maybe this is useful for someone looking to create a similar wrapper in this project?
|
@rolftimmermans thanks. @romandev FYI, in case you are first to get to working on adding support to the wrapper for callback scopes. |
Hi everyone I think that this issue could be close when we will land this PR #362 Is it right? |
@mhdawson could we close this issue now? |
Closing |
I'm closing this, we just released version 1.6.0 that contains the |
Now that nodejs/node#18089 has landed we should add equivalent support in node-addon-api.
The text was updated successfully, but these errors were encountered: