summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-heap-snapshot.js
blob: 5358f2effca508fe9384cd481ab18e75393b8345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';

const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
const { once } = require('events');

// Ensure that worker.getHeapSnapshot() returns a valid JSON
(async () => {
  const worker = new Worker('setInterval(() => {}, 1000);', { eval: true });
  await once(worker, 'online');
  const stream = await worker.getHeapSnapshot();
  assert.ok(JSON.parse(stream.read()));

  await worker.terminate();
})().then(common.mustCall());