Skip to content

Commit 2b34867

Browse files
BridgeARtargos
authored andcommitted
v8: fix missing callback in heap utils destroy
This fixes the v8.getHeapSnapshot() calls not properly being destroyed. Pipeline calls would for example not properly end without the callback being in place. PR-URL: #58846 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent c76585d commit 2b34867

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/internal/heap_utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ class HeapSnapshotStream extends Readable {
5353
this[kHandle].readStart();
5454
}
5555

56-
_destroy() {
56+
_destroy(err, callback) {
5757
// Release the references on the handle so that
5858
// it can be garbage collected.
5959
this[kHandle][owner_symbol] = undefined;
6060
this[kHandle] = undefined;
61+
callback(err);
6162
}
6263

6364
[kUpdateTimer]() {

test/sequential/test-heapdump.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if (!isMainThread) {
1010
const { writeHeapSnapshot, getHeapSnapshot } = require('v8');
1111
const assert = require('assert');
1212
const fs = require('fs');
13+
const { promises: { pipeline }, PassThrough } = require('stream');
1314
const tmpdir = require('../common/tmpdir');
1415

1516
tmpdir.refresh();
@@ -78,3 +79,13 @@ process.chdir(tmpdir.path);
7879
JSON.parse(data);
7980
}));
8081
}
82+
83+
{
84+
const passthrough = new PassThrough();
85+
passthrough.on('data', common.mustCallAtLeast(1));
86+
87+
pipeline(
88+
getHeapSnapshot(),
89+
passthrough,
90+
).then(common.mustCall());
91+
}

0 commit comments

Comments
 (0)