mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
17 lines
502 B
JavaScript
17 lines
502 B
JavaScript
|
'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());
|