| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c14e4d5 commit 2053dd0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,8 +169,10 @@ class ReadableWorkerStdio extends Readable { | |||
| 169 | 169 | this[kIncrementsPortRef] = true; | |
| 170 | 170 | this[kStartedReading] = false; | |
| 171 | 171 | this.on('end', () => { | |
| 172 | - if (this[kIncrementsPortRef] && --this[kPort][kWaitingStreams] === 0) | ||
| 173 | - this[kPort].unref(); | ||
| 172 | + if (this[kStartedReading] && this[kIncrementsPortRef]) { | ||
| 173 | + if (--this[kPort][kWaitingStreams] === 0) | ||
| 174 | + this[kPort].unref(); | ||
| 175 | + } | ||
| 174 | 176 | }); | |
| 175 | 177 | } | |
| 176 | 178 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { Worker, isMainThread } = require('worker_threads'); | ||
| 5 | + | ||
| 6 | + // Regression test for https://github.com/nodejs/node/issues/28144. | ||
| 7 | + | ||
| 8 | + if (isMainThread) { | ||
| 9 | + const w = new Worker(__filename); | ||
| 10 | + w.on('exit', common.mustCall((status) => { | ||
| 11 | + assert.strictEqual(status, 0); | ||
| 12 | + })); | ||
| 13 | + w.stdout.on('data', common.mustCall(10)); | ||
| 14 | + } else { | ||
| 15 | + process.stdin.on('data', () => {}); | ||
| 16 | + | ||
| 17 | + for (let i = 0; i < 10; ++i) { | ||
| 18 | + process.stdout.write(`processing(${i})\n`, common.mustCall()); | ||
| 19 | + } | ||
| 20 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments