stream: throw invalid arg type from End Of Stream · nodejs/node@fe7ca08 · GitHub
Skip to content

Commit fe7ca08

Browse files
authored
stream: throw invalid arg type from End Of Stream
PR-URL: #41766 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mary Marchini <oss@mmarchini.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent bde184e commit fe7ca08

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

lib/internal/streams/end-of-stream.js

Lines changed: 2 additions & 1 deletion
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
5+
const { Duplex, finished } = require('stream');
6+
7+
assert.throws(
8+
() => {
9+
// Passing empty object to mock invalid stream
10+
// should throw error
11+
finished({}, () => {});
12+
},
13+
{ code: 'ERR_INVALID_ARG_TYPE' }
14+
);
15+
16+
const streamObj = new Duplex();
17+
streamObj.end();
18+
// Below code should not throw any errors as the
19+
// streamObj is `Stream`
20+
finished(streamObj, () => {});

test/parallel/test-stream-finished.js

Lines changed: 6 additions & 1 deletion

0 commit comments

Comments
 (0)