| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,7 +116,7 @@ function eos(stream, options, callback) { | |||
| 116 | 116 | return callback.call(stream, errored); | |
| 117 | 117 | } | |
| 118 | 118 | ||
| 119 | - if (readable && !readableFinished) { | ||
| 119 | + if (readable && !readableFinished && isReadableNodeStream(stream, true)) { | ||
| 120 | 120 | if (!isReadableFinished(stream, false)) | |
| 121 | 121 | return callback.call(stream, | |
| 122 | 122 | new ERR_STREAM_PREMATURE_CLOSE()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,11 +9,15 @@ const { | |||
| 9 | 9 | const kDestroyed = Symbol('kDestroyed'); | |
| 10 | 10 | const kIsDisturbed = Symbol('kIsDisturbed'); | |
| 11 | 11 | ||
| 12 | - function isReadableNodeStream(obj) { | ||
| 12 | + function isReadableNodeStream(obj, strict = false) { | ||
| 13 | 13 | return !!( | |
| 14 | 14 | obj && | |
| 15 | 15 | typeof obj.pipe === 'function' && | |
| 16 | 16 | typeof obj.on === 'function' && | |
| 17 | + ( | ||
| 18 | + !strict || | ||
| 19 | + (typeof obj.pause === 'function' && typeof obj.resume === 'function') | ||
| 20 | + ) && | ||
| 17 | 21 | (!obj._writableState || obj._readableState?.readable !== false) && // Duplex | |
| 18 | 22 | (!obj._writableState || obj._readableState) // Writable has .pipe. | |
| 19 | 23 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -639,3 +639,20 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); | |||
| 639 | 639 | const s = new Stream(); | |
| 640 | 640 | finished(s, common.mustNotCall()); | |
| 641 | 641 | } | |
| 642 | + | ||
| 643 | + { | ||
| 644 | + const server = http.createServer(common.mustCall(function(req, res) { | ||
| 645 | + fs.createReadStream(__filename).pipe(res); | ||
| 646 | + finished(res, common.mustCall(function(err) { | ||
| 647 | + assert.strictEqual(err, undefined); | ||
| 648 | + })); | ||
| 649 | + })).listen(0, function() { | ||
| 650 | + http.request( | ||
| 651 | + { method: 'GET', port: this.address().port }, | ||
| 652 | + common.mustCall(function(res) { | ||
| 653 | + res.resume(); | ||
| 654 | + server.close(); | ||
| 655 | + }) | ||
| 656 | + ).end(); | ||
| 657 | + }); | ||
| 658 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments