Skip to content

n-api: napi_wrap-ped finalize_cb not invoked #22396

Description

@legendecas
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to the Node-API.testIssues and PRs related to the tests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions