11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst { Worker, workerData } = require('worker_threads'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Test that 'exit' events for nested Workers are not received when a Worker 71cb0ef41Sopenharmony_ci// terminates itself through process.exit(). 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciif (workerData === null) { 101cb0ef41Sopenharmony_ci const nestedWorkerExitCounter = new Int32Array(new SharedArrayBuffer(4)); 111cb0ef41Sopenharmony_ci const w = new Worker(__filename, { workerData: nestedWorkerExitCounter }); 121cb0ef41Sopenharmony_ci w.on('exit', common.mustCall(() => { 131cb0ef41Sopenharmony_ci assert.strictEqual(nestedWorkerExitCounter[0], 0); 141cb0ef41Sopenharmony_ci })); 151cb0ef41Sopenharmony_ci} else { 161cb0ef41Sopenharmony_ci const nestedWorker = new Worker('setInterval(() => {}, 100)', { eval: true }); 171cb0ef41Sopenharmony_ci // The counter should never be increased here. 181cb0ef41Sopenharmony_ci nestedWorker.on('exit', () => workerData[0]++); 191cb0ef41Sopenharmony_ci nestedWorker.on('online', () => process.exit()); 201cb0ef41Sopenharmony_ci} 21