11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// This used to crash because the `.unref()` was unexpected while the Worker 61cb0ef41Sopenharmony_ci// was exiting. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst w = new Worker(` 91cb0ef41Sopenharmony_cirequire('worker_threads').parentPort.postMessage({}); 101cb0ef41Sopenharmony_ci`, { eval: true }); 111cb0ef41Sopenharmony_ciw.on('message', common.mustCall(() => { 121cb0ef41Sopenharmony_ci w.unref(); 131cb0ef41Sopenharmony_ci})); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// Wait a bit so that the 'message' event is emitted while the Worker exits. 161cb0ef41Sopenharmony_ciAtomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100); 17