Skip to content
Merged
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
Next Next commit
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.
  • Loading branch information
BridgeAR committed Jun 26, 2025
commit dc84c55baa732b56d36664ef58812c44ac607b9b
3 changes: 2 additions & 1 deletion lib/internal/heap_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ class HeapSnapshotStream extends Readable {
this[kHandle].readStart();
}

_destroy() {
_destroy(err, callback) {
// Release the references on the handle so that
// it can be garbage collected.
this[kHandle][owner_symbol] = undefined;
this[kHandle] = undefined;
callback(err);
}

[kUpdateTimer]() {
Expand Down
13 changes: 13 additions & 0 deletions test/sequential/test-heapdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
const { writeHeapSnapshot, getHeapSnapshot } = require('v8');
const assert = require('assert');
const fs = require('fs');
const { promises: { pipeline }, PassThrough } = require('stream');
const tmpdir = require('../common/tmpdir');

tmpdir.refresh();
Expand Down Expand Up @@ -78,3 +79,15 @@
JSON.parse(data);
}));
}

{
const passthrough = new PassThrough();
passthrough.on('data', common.mustCallAtLeast(()=> {

Check failure on line 85 in test/sequential/test-heapdump.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing space before =>

Check failure on line 85 in test/sequential/test-heapdump.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Do not use an empty function, omit the parameter altogether
// Do nothing, just consume the data
}, 1));

pipeline(
getHeapSnapshot(),
passthrough,
).then(common.mustCall());
}
Loading