mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

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>
27 lines
899 B
JavaScript
27 lines
899 B
JavaScript
'use strict';
|
|
|
|
// This tests heap snapshot integration of worker.
|
|
|
|
require('../common');
|
|
const { validateByRetainingPath } = require('../common/heap');
|
|
const { Worker } = require('worker_threads');
|
|
const assert = require('assert');
|
|
|
|
// Before worker is used, no MessagePort should be created.
|
|
{
|
|
const nodes = validateByRetainingPath('Node / Worker', []);
|
|
assert.strictEqual(nodes.length, 0);
|
|
}
|
|
|
|
const worker = new Worker('setInterval(() => {}, 100);', { eval: true });
|
|
// When a worker is alive, a Worker instance and its message port should be captured.
|
|
{
|
|
validateByRetainingPath('Node / Worker', [
|
|
{ node_name: 'Worker', edge_name: 'native_to_javascript' },
|
|
{ node_name: 'MessagePort', edge_name: 'messagePort' },
|
|
{ node_name: 'Node / MessagePort', edge_name: 'javascript_to_native' },
|
|
{ node_name: 'Node / MessagePortData', edge_name: 'data' },
|
|
]);
|
|
}
|
|
|
|
worker.terminate();
|