11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst { Worker, MessageChannel } = require('worker_threads'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Check the interaction of calling .terminate() while transferring 61cb0ef41Sopenharmony_ci// MessagePort objects; in particular, that it does not crash the process. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cifor (let i = 0; i < 10; ++i) { 91cb0ef41Sopenharmony_ci const w = new Worker( 101cb0ef41Sopenharmony_ci "require('worker_threads').parentPort.on('message', () => {})", 111cb0ef41Sopenharmony_ci { eval: true }); 121cb0ef41Sopenharmony_ci setImmediate(() => { 131cb0ef41Sopenharmony_ci const port = new MessageChannel().port1; 141cb0ef41Sopenharmony_ci w.postMessage({ port }, [ port ]); 151cb0ef41Sopenharmony_ci w.terminate(); 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci} 18