Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/js_native_api_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ class Finalizer {
_finalize_callback(finalize_callback),
_finalize_data(finalize_data),
_finalize_hint(finalize_hint) {
_env->Ref();
}

~Finalizer() = default;
~Finalizer() {
_env->Unref();
}

public:
static Finalizer* New(napi_env env,
Expand Down
14 changes: 14 additions & 0 deletions test/node-api/test_buffer/test-external-buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/test_buffer`);
const assert = require('assert');

// Regresion test for https://github.com/nodejs/node/issues/31134:
Comment thread
addaleax marked this conversation as resolved.
Outdated
// 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);