| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe2cd09 commit 16ee842
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ const { | |||
| 33 | 33 | isIterable, | |
| 34 | 34 | isReadableNodeStream, | |
| 35 | 35 | isNodeStream, | |
| 36 | + isReadableFinished, | ||
| 36 | 37 | } = require('internal/streams/utils'); | |
| 37 | 38 | const { AbortController } = require('internal/abort_controller'); | |
| 38 | 39 | ||
@@ -229,7 +230,14 @@ function pipelineImpl(streams, callback, opts) { | |||
| 229 | 230 | ||
| 230 | 231 | if (isNodeStream(stream)) { | |
| 231 | 232 | finishCount++; | |
| 232 | - destroys.push(destroyer(stream, reading, writing, finish)); | ||
| 233 | + destroys.push(destroyer(stream, reading, writing, (err) => { | ||
| 234 | + if (!err && !reading && isReadableFinished(stream, false)) { | ||
| 235 | + stream.read(0); | ||
| 236 | + destroyer(stream, true, writing, finish); | ||
| 237 | + } else { | ||
| 238 | + finish(err); | ||
| 239 | + } | ||
| 240 | + })); | ||
| 233 | 241 | } | |
| 234 | 242 | ||
| 235 | 243 | if (i === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1027,7 +1027,7 @@ const tsp = require('timers/promises'); | |||
| 1027 | 1027 | const src = new PassThrough(); | |
| 1028 | 1028 | const dst = new PassThrough(); | |
| 1029 | 1029 | pipeline(src, dst, common.mustSucceed(() => { | |
| 1030 | - assert.strictEqual(dst.destroyed, false); | ||
| 1030 | + assert.strictEqual(dst.destroyed, true); | ||
| 1031 | 1031 | })); | |
| 1032 | 1032 | src.end(); | |
| 1033 | 1033 | } | |
@@ -1447,3 +1447,23 @@ const tsp = require('timers/promises'); | |||
| 1447 | 1447 | assert.strictEqual(text, 'Hello World!'); | |
| 1448 | 1448 | })); | |
| 1449 | 1449 | } | |
| 1450 | + | ||
| 1451 | + { | ||
| 1452 | + const pipelinePromise = promisify(pipeline); | ||
| 1453 | + | ||
| 1454 | + async function run() { | ||
| 1455 | + const read = new Readable({ | ||
| 1456 | + read() {} | ||
| 1457 | + }); | ||
| 1458 | + | ||
| 1459 | + const duplex = new PassThrough(); | ||
| 1460 | + | ||
| 1461 | + read.push(null); | ||
| 1462 | + | ||
| 1463 | + await pipelinePromise(read, duplex); | ||
| 1464 | + | ||
| 1465 | + assert.strictEqual(duplex.destroyed, true); | ||
| 1466 | + } | ||
| 1467 | + | ||
| 1468 | + run(); | ||
| 1469 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments