-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
ObjectWrap
destructors run after CleanupHook
#45088
Comments
CleanupHook
ObjectWrap
destructors run after CleanupHook
cc @nodejs/node-api |
Currently, the document only defines that cleanup hooks are run in a reversed order, but no words on if the cleanup hooks are run before any other finalizers. As the status quo, all cleanup hooks are run before the finalizers, regardless of their registration order, as the napi_env's own cleanup is registered before the registration of any addon's cleanup hooks. I believe it would be more reasonable to run cleanup hooks after pending finalizers are drained. After the cleanup hooks are invoked, there should be no callbacks can calling into the addon again. |
Hi @legendecas , could this issue also be related to TSFN "release in ObjectWrap destructor" crash stacktraces we are seeing in nodejs/node-addon-api#1109? |
@KevinEady thanks for the link. At first sight, it seems like a finalization order problem too. I'll take a look at both issues. |
As status quo, the cleanup hooks are invoked before the `napi_finalize` callbacks at the exit of Node.js environments. This gives addons a chance to release their resource in a proper order manually. Document this behavior explicitly to advocate the usage on cleanup hooks instead of relying on the implied invocation of `napi_finalize` callbacks at shutdown. PR-URL: #45903 Fixes: #45088 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
As status quo, the cleanup hooks are invoked before the `napi_finalize` callbacks at the exit of Node.js environments. This gives addons a chance to release their resource in a proper order manually. Document this behavior explicitly to advocate the usage on cleanup hooks instead of relying on the implied invocation of `napi_finalize` callbacks at shutdown. PR-URL: #45903 Fixes: #45088 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
As status quo, the cleanup hooks are invoked before the `napi_finalize` callbacks at the exit of Node.js environments. This gives addons a chance to release their resource in a proper order manually. Document this behavior explicitly to advocate the usage on cleanup hooks instead of relying on the implied invocation of `napi_finalize` callbacks at shutdown. PR-URL: #45903 Fixes: #45088 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
As status quo, the cleanup hooks are invoked before the `napi_finalize` callbacks at the exit of Node.js environments. This gives addons a chance to release their resource in a proper order manually. Document this behavior explicitly to advocate the usage on cleanup hooks instead of relying on the implied invocation of `napi_finalize` callbacks at shutdown. PR-URL: #45903 Fixes: #45088 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Version
16.17.0
Platform
Ubuntu 20.04
Subsystem
napi
What steps will reproduce the bug?
Having
ObjectWrap
objects when destroying the environment. May be related to having stalePersistent
objects.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
All C++ objects are destroyed before the
CleanupHook
What do you see instead?
This is the stack trace
Additional information
No response
The text was updated successfully, but these errors were encountered: