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
28
29
30
|
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
const { once } = require('events');
(async function() {
const w = new Worker('', { eval: true });
await once(w, 'exit');
await assert.rejects(() => w.getHeapSnapshot(), {
name: 'Error',
code: 'ERR_WORKER_NOT_RUNNING'
});
})().then(common.mustCall());
(async function() {
const worker = new Worker('setInterval(() => {}, 1000);', { eval: true });
await once(worker, 'online');
[1, true, [], null, Infinity, NaN].forEach((i) => {
assert.throws(() => worker.getHeapSnapshot(i), {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "options" argument must be of type object.' +
common.invalidArgTypeHelper(i)
});
});
await worker.terminate();
})().then(common.mustCall());
|