11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Check that `process.exit()` can be called inside a Worker from an uncaught 71cb0ef41Sopenharmony_ci// exception handler. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Do not use isMainThread so that this test itself can be run inside a Worker. 101cb0ef41Sopenharmony_ciif (!process.env.HAS_STARTED_WORKER) { 111cb0ef41Sopenharmony_ci process.env.HAS_STARTED_WORKER = 1; 121cb0ef41Sopenharmony_ci const w = new Worker(__filename); 131cb0ef41Sopenharmony_ci w.on('exit', common.mustCall((code) => { 141cb0ef41Sopenharmony_ci assert.strictEqual(code, 42); 151cb0ef41Sopenharmony_ci })); 161cb0ef41Sopenharmony_ci return; 171cb0ef41Sopenharmony_ci} 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciprocess.on('uncaughtException', () => { 201cb0ef41Sopenharmony_ci process.exit(42); 211cb0ef41Sopenharmony_ci}); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_cithrow new Error(); 24