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

Documentation: Mention that Napi::Reference must not be stored in a global static instance #162

Closed
gabrielschulhof opened this issue Oct 24, 2017 · 4 comments

Comments

@gabrielschulhof
Copy link
Contributor

This must be avoided because Reference calls napi_delete_reference(), which in turn calls Reset() on the persistent stored inside, which ends up crashing because it runs from the library destructor, which in turn runs after the Isolate has already been disposed of.

See the source.

@jschlight
Copy link
Contributor

The Reference SuppressDestruct method permits the user to set a private data member that avoids the napi_delete_reference call in ~Reference. Would calling SuppressDestruct permit the Reference to be a global static instance?

@jschlight
Copy link
Contributor

jschlight commented Mar 29, 2018

This issue can be closed when PR #243 lands.

@NickNaso
Copy link
Member

NickNaso commented Sep 3, 2018

@gabrielschulhof Could be possible close this issue? The Napi::Reference documentation was landed with PR #243

@NickNaso
Copy link
Member

I'm closing this issue it was solved with PR #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants