Skip to content

Commit 077d502

Browse files
BridgeARmarco-ippolito
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 <ethan@arrowood.dev> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
1 parent 0dd3a8d commit 077d502

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
@@ -8,6 +8,7 @@ if (!common.isMainThread)
88
const { writeHeapSnapshot, getHeapSnapshot } = require('v8');
99
const assert = require('assert');
1010
const fs = require('fs');
11+
const { promises: { pipeline }, PassThrough } = require('stream');
1112
const tmpdir = require('../common/tmpdir');
1213

1314
tmpdir.refresh();
@@ -76,3 +77,13 @@ process.chdir(tmpdir.path);
7677
JSON.parse(data);
7778
}));
7879
}
80+
81+
{
82+
const passthrough = new PassThrough();
83+
passthrough.on('data', common.mustCallAtLeast(1));
84+
85+
pipeline(
86+
getHeapSnapshot(),
87+
passthrough,
88+
).then(common.mustCall());
89+
}

0 commit comments

Comments
 (0)