forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-heapdump-worker.js
More file actions
27 lines (22 loc) · 899 Bytes
/
Copy pathtest-heapdump-worker.js
File metadata and controls
27 lines (22 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'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();