mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
b872d30d19
Support configuration of the HeapSnapshotMode and NumericsMode fields inf HeapSnapshotOptions in the JS APIs for heap snapshots. PR-URL: https://github.com/nodejs/node/pull/44989 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
31 lines
882 B
JavaScript
31 lines
882 B
JavaScript
'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());
|