-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: napi_wrap-ped finalize_cb not invoked #22396
Comments
I think you are suggesting we should update the test, I agree? Do you want to open a PR to do that? |
Yes, if possible. But I didn't figure out why in bare context objects' finalize callback was not invoked, since objects should be gc-ed on exit right? |
I don't think there is any requirement for a gc on exit. Unless there is somewhere in the JS spec that says finalizers will be invoked before exit (my guess is that there is not) then the process can simply exist and all memory is freed so no reason to run a gc first. |
Sounds reasonable to me that there is no reason to run gc first before exit. More question: whether finalize callback shall be ensured to be invoked in this test case? IMO there are reasons to test it to cover napi wraps. |
It would be would to have the test case cover the callback being invoked if possible. Do you want to update PR to update the test to validate that? |
@mhdawson PR is submitted :p |
@legendecas the finalizer will be called if you do let obj1 = createObject(10);
obj1 = null;
global.gc(); so this is not actually a bug. |
@legendecas we actually check exactly that the finalizer gets called in https://github.com/nodejs/node/blob/master/test/addons-napi/8_passing_wrapped/test.js. |
It seems
napi_wrap
ed object'sfinalize_cb
is not called on test case: https://github.com/nodejs/node/blob/v10.9.0/test/addons-napi/7_factory_wrap/myobject.cc#L8Yet if we wrap the JS code https://github.com/nodejs/node/blob/v10.9.0/test/addons-napi/7_factory_wrap/test.js#L6-L14 with a function context and force gc like following:
the
finalize_cb
does be called.The text was updated successfully, but these errors were encountered: