| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3b46e7f commit 1c64bc5
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,7 @@ if (process.env.NODE_CHANNEL_FD) { | |||
| 92 | 92 | ||
| 93 | 93 | port.on('message', (message) => { | |
| 94 | 94 | if (message.type === LOAD_SCRIPT) { | |
| 95 | + port.unref(); | ||
| 95 | 96 | const { | |
| 96 | 97 | argv, | |
| 97 | 98 | cwdCounter, | |
@@ -140,7 +141,6 @@ port.on('message', (message) => { | |||
| 140 | 141 | ||
| 141 | 142 | debug(`[${threadId}] starts worker script ${filename} ` + | |
| 142 | 143 | `(eval = ${eval}) at cwd = ${process.cwd()}`); | |
| 143 | - port.unref(); | ||
| 144 | 144 | port.postMessage({ type: UP_AND_RUNNING }); | |
| 145 | 145 | if (doEval) { | |
| 146 | 146 | const { evalScript } = require('internal/process/execution'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const fixtures = require('../common/fixtures'); | ||
| 4 | + const { Worker } = require('worker_threads'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + | ||
| 7 | + // Regression test for https://github.com/nodejs/node/issues/31777: | ||
| 8 | + // stdio operations coming from preload modules should count towards the | ||
| 9 | + // ref count of the internal communication port on the Worker side. | ||
| 10 | + | ||
| 11 | + for (let i = 0; i < 10; i++) { | ||
| 12 | + const w = new Worker('console.log("B");', { | ||
| 13 | + execArgv: ['--require', fixtures.path('printA.js')], | ||
| 14 | + eval: true, | ||
| 15 | + stdout: true | ||
| 16 | + }); | ||
| 17 | + w.on('exit', common.mustCall(() => { | ||
| 18 | + assert.strictEqual(w.stdout.read().toString(), 'A\nB\n'); | ||
| 19 | + })); | ||
| 20 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments