Skip to content
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

Extend N-API to cover libnode #43516

Closed
mmomtchev opened this issue Jun 21, 2022 · 5 comments
Closed

Extend N-API to cover libnode #43516

mmomtchev opened this issue Jun 21, 2022 · 5 comments
Labels
feature request Issues that request new features to be added to Node.js. node-api Issues and PRs related to the Node-API.

Comments

@mmomtchev
Copy link
Contributor

What is the problem this feature will solve?

Currently when using libnode one has to use raw V8 primitives or to manually construct a napi_env by including node_api_internals.h which is normally not exported and has other internal dependencies.

What is the feature you are proposing to solve the problem?

Add a N-API primitive for creating a Node environment (the code in embedtest.cc) that constructs a napi_env

What alternatives have you considered?

  • Using raw V8 primitives - very impractical and not portable
  • Including node_api_internals.h and manually constructing a napi_env - requires access to Node internal structures that are normally not exported
@mmomtchev mmomtchev added the feature request Issues that request new features to be added to Node.js. label Jun 21, 2022
@VoltrexKeyva VoltrexKeyva added the node-api Issues and PRs related to the Node-API. label Jun 21, 2022
@legendecas
Copy link
Member

Duplicate of #23265

@legendecas legendecas marked this as a duplicate of #23265 Jun 24, 2022
@mmomtchev
Copy link
Contributor Author

@legendecas one very significant difference of this proposal and my implementation is that draining the event loop is a separate API call - something that I did consider too. I wonder if there is any point in doing this? The current implementation does not allow to wait for all async tasks to finish and then to reuse the environment - at this point it must be destroyed.
Also I see an API call for creating an environment out of a libuv event loop? Is it needed?

@legendecas
Copy link
Member

The current implementation does not allow to wait for all async tasks to finish and then to reuse the environment - at this point it must be destroyed.

I'm not sure I get your point about "current implementation" correctly. If you are referring to the Node.js embedder API, I think people can already get the uv loop and drain the queue with APIs like node::GetCurrentEventLoop.

@mmomtchev
Copy link
Contributor Author

@legendecas I am open to all constructive suggestions.

@mmomtchev
Copy link
Contributor Author

I am closing this issue so that there is a single discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

No branches or pull requests

3 participants