Skip to content

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

Closed
@legendecas

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';
const common = require('../../common');
const assert = require('assert');
const createObject = require(`./build/${common.buildType}/binding`);

function context() {
  const obj = createObject(10);
  assert.strictEqual(obj.plusOne(), 11);
  assert.strictEqual(obj.plusOne(), 12);
  assert.strictEqual(obj.plusOne(), 13);

  const obj2 = 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