node/test/pummel/test-heapdump-dns.js
Joyee Cheung e86adad759 test: use validateByRetainingPath in heapdump tests
This makes sure that the tests are run on actual heap snapshots
and prints out missing paths when it cannot be found, which
makes failures easier to debug, and removes the unnecessary
requirement for BaseObjects to be root - which would make
the heap snapshot containment view rather noisy and is not
conceptually correct, since they are actually held by the
BaseObjectList held by the realms.

PR-URL: https://github.com/nodejs/node/pull/57417
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-04-27 19:00:05 +00:00

32 lines
893 B
JavaScript

'use strict';
// This tests heap snapshot integration of dns ChannelWrap.
require('../common');
const { validateByRetainingPath } = require('../common/heap');
const assert = require('assert');
// Before dns is loaded, no ChannelWrap should be created.
{
const nodes = validateByRetainingPath('Node / ChannelWrap', []);
assert.strictEqual(nodes.length, 0);
}
const dns = require('dns');
// Right after dns is loaded, a ChannelWrap should be created for the default
// resolver, but it has no task list.
{
validateByRetainingPath('Node / ChannelWrap', [
{ node_name: 'ChannelWrap', edge_name: 'native_to_javascript' },
]);
}
dns.resolve('localhost', () => {});
// After dns resolution, the ChannelWrap of the default resolver has the task list.
{
validateByRetainingPath('Node / ChannelWrap', [
{ node_name: 'Node / NodeAresTask::List', edge_name: 'task_list' },
]);
}