summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-finished.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2020-01-28 07:05:03 +0100
committerRobert Nagy <ronagy@icloud.com>2020-03-03 13:34:24 +0100
commit7cafd5f3a924451294a4f2ce6efb628b53fce7eb (patch)
treef27208bde244d1f8a6a2063cde358c151fa17a25 /test/parallel/test-stream-finished.js
parent3ec4b21b1c438255df6f1652377011080dc28052 (diff)
downloadnode-new-7cafd5f3a924451294a4f2ce6efb628b53fce7eb.tar.gz
stream: fix finished w/ 'close' before 'end'
Emitting 'close' before 'end' on a Readable should result in a premature close error. PR-URL: https://github.com/nodejs/node/pull/31545 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-finished.js')
-rw-r--r--test/parallel/test-stream-finished.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js
index c9c6bafd64..46a5f93913 100644
--- a/test/parallel/test-stream-finished.js
+++ b/test/parallel/test-stream-finished.js
@@ -342,3 +342,13 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
d._writableState.errored = true;
d.emit('close');
}
+
+{
+ const r = new Readable();
+ finished(r, common.mustCall((err) => {
+ assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
+ }));
+ r.push('asd');
+ r.push(null);
+ r.destroy();
+}