11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 61cb0ef41Sopenharmony_ciconst { once } = require('events'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci// Ensure that worker.getHeapSnapshot() returns a valid JSON 91cb0ef41Sopenharmony_ci(async () => { 101cb0ef41Sopenharmony_ci const worker = new Worker('setInterval(() => {}, 1000);', { eval: true }); 111cb0ef41Sopenharmony_ci await once(worker, 'online'); 121cb0ef41Sopenharmony_ci const stream = await worker.getHeapSnapshot(); 131cb0ef41Sopenharmony_ci assert.ok(JSON.parse(stream.read())); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci await worker.terminate(); 161cb0ef41Sopenharmony_ci})().then(common.mustCall()); 17