mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
ba5b5acaf1
PR-URL: https://github.com/nodejs/node/pull/41818 Refs: https://coverage.nodejs.org/coverage-7123a00b03a90862/lib/internal/worker.js.html#L412 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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());
|