Skip to content

Commit dc84c55

Browse files
committed
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.
1 parent 4d849a1 commit dc84c55

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-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: 13 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,15 @@ process.chdir(tmpdir.path);
7879
JSON.parse(data);
7980
}));
8081
}
82+
83+
{
84+
const passthrough = new PassThrough();
85+
passthrough.on('data', common.mustCallAtLeast(()=> {
86+
// Do nothing, just consume the data
87+
}, 1));
88+
89+
pipeline(
90+
getHeapSnapshot(),
91+
passthrough,
92+
).then(common.mustCall());
93+
}

0 commit comments

Comments
 (0)