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

N-API: Lifetime of napi_env is unclear #31003

Closed
argv-minus-one opened this issue Dec 17, 2019 · 1 comment
Closed

N-API: Lifetime of napi_env is unclear #31003

argv-minus-one opened this issue Dec 17, 2019 · 1 comment
Labels
node-api Issues and PRs related to the Node-API.

Comments

@argv-minus-one
Copy link

The N-API documentation says not to keep napi_env values around. This would seem to imply that napi_env values are valid only for the duration of a single call into native code (the module initializer, a native function call, etc).

However, in the C++ wrapper, the Reference class (which is meant to live longer than a single native call) keeps a long-lived napi_env value around, seemingly violating the documented lifetime!

Please clarify the lifetime of napi_env values in the documentation. Just how long is a napi_env really valid for? A single native call? The entire time until the env_shutdown_hooks are run and the native module is unloaded? Somewhere in between?

@legendecas legendecas added the node-api Issues and PRs related to the Node-API. label Dec 17, 2019
@legendecas
Copy link
Member

Fixed by #31102. Please reopen freely if needed.

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

Successfully merging a pull request may close this issue.

2 participants