11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/31777: 81cb0ef41Sopenharmony_ci// stdio operations coming from preload modules should count towards the 91cb0ef41Sopenharmony_ci// ref count of the internal communication port on the Worker side. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifor (let i = 0; i < 10; i++) { 121cb0ef41Sopenharmony_ci const w = new Worker('console.log("B");', { 131cb0ef41Sopenharmony_ci execArgv: ['--require', fixtures.path('printA.js')], 141cb0ef41Sopenharmony_ci eval: true, 151cb0ef41Sopenharmony_ci stdout: true 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci w.on('exit', common.mustCall(() => { 181cb0ef41Sopenharmony_ci assert.strictEqual(w.stdout.read().toString(), 'A\nB\n'); 191cb0ef41Sopenharmony_ci })); 201cb0ef41Sopenharmony_ci} 21