- Version: 10.9.0
- Platform: macOS
- Subsystem: n-api
It seems napi_wraped object's finalize_cb is not called on test case: https://github.com/nodejs/node/blob/v10.9.0/test/addons-napi/7_factory_wrap/myobject.cc#L8
Yet 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:
'use strict';constcommon=require('../../common');constassert=require('assert');constcreateObject=require(`./build/${common.buildType}/binding`);functioncontext(){constobj=createObject(10);assert.strictEqual(obj.plusOne(),11);assert.strictEqual(obj.plusOne(),12);assert.strictEqual(obj.plusOne(),13);constobj2=createObject(20);assert.strictEqual(obj2.plusOne(),21);assert.strictEqual(obj2.plusOne(),22);assert.strictEqual(obj2.plusOne(),23);}context();global.gc();the finalize_cb does be called.
It seems
napi_wraped object'sfinalize_cbis 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_cbdoes be called.