File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ function merge2 () {
6464
6565 stream . on ( 'merge2UnpipeEnd' , onend )
6666 stream . on ( 'end' , onend )
67+ stream . on ( 'error' , function ( err ) {
68+ mergedStream . emit ( 'error' , err )
69+ } )
6770 stream . pipe ( mergedStream , { end : false } )
6871 // compatible for old stream
6972 stream . resume ( )
Original file line number Diff line number Diff line change @@ -47,6 +47,26 @@ function test (merge2) {
4747 } )
4848 } )
4949
50+ tman . it ( 'merge2 - error handling' , function ( done ) {
51+ const ts = through . obj ( )
52+
53+ const mergeStream = merge2 ( toThrough ( ts ) )
54+
55+ const expectedError = new Error ( 'error' )
56+ thunk . delay ( 100 ) ( function ( ) {
57+ ts . destroy ( expectedError )
58+ } )
59+
60+ mergeStream
61+ . on ( 'error' , function ( error ) {
62+ assert . strictEqual ( error , expectedError )
63+ done ( )
64+ } )
65+ . on ( 'end' , function ( ) {
66+ throw Error ( 'error expected' )
67+ } )
68+ } )
69+
5070 tman . it ( 'merge2(TransformStream)' , function ( done ) {
5171 const result = [ ]
5272 const ts = through . obj ( )
You can’t perform that action at this time.
0 commit comments