forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: finish pipeline if dst closes before src
If the destination stream is closed before the source has completed the pipeline should finnish with premature close. Fixes: nodejs#43682
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { pipeline, Duplex, PassThrough } = require('stream'); | ||
const assert = require('assert'); | ||
|
||
const remote = new PassThrough(); | ||
const local = new Duplex({ | ||
read () {}, | ||
write (chunk, enc, callback) { | ||
callback() | ||
} | ||
}); | ||
|
||
pipeline(remote, local, remote, common.mustCall((err) => { | ||
assert.equal(err.code, 'ERR_STREAM_PREMATURE_CLOSE') | ||
})); | ||
|
||
setImmediate(() => { | ||
remote.end(); | ||
}); |