mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
n-api: keep napi_env alive while it has finalizers
Manage the napi_env refcount from Finalizer instances, as the finalizer may refer to the napi_env until it is deleted. Fixes: https://github.com/nodejs/node/issues/31134 Fixes: https://github.com/node-ffi-napi/node-ffi-napi/issues/48 PR-URL: https://github.com/nodejs/node/pull/31140 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
d845915d46
commit
493faf606d
3 changed files with 39 additions and 6 deletions
14
test/node-api/test_buffer/test-external-buffer.js
Normal file
14
test/node-api/test_buffer/test-external-buffer.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../../common');
|
||||
const binding = require(`./build/${common.buildType}/test_buffer`);
|
||||
const assert = require('assert');
|
||||
|
||||
// Regression test for https://github.com/nodejs/node/issues/31134
|
||||
// Buffers with finalizers are allowed to remain alive until
|
||||
// Environment cleanup without crashing the process.
|
||||
// The test stores the buffer on `process` to make sure it lives as long as
|
||||
// the Context does.
|
||||
|
||||
process.externalBuffer = binding.newExternalBuffer();
|
||||
assert.strictEqual(process.externalBuffer.toString(), binding.theText);
|
Loading…
Add table
Add a link
Reference in a new issue