@@ -8,19 +8,20 @@ const stream = require('stream');
88 // Invoke end callback on failure.
99 const writable = new stream . Writable ( ) ;
1010
11+ const _err = new Error ( 'kaboom' ) ;
1112 writable . _write = ( chunk , encoding , cb ) => {
12- process . nextTick ( cb , new Error ( 'kaboom' ) ) ;
13+ process . nextTick ( cb , _err ) ;
1314 } ;
1415
1516 writable . on ( 'error' , common . mustCall ( ( err ) => {
16- assert . strictEqual ( err . message , 'kaboom' ) ;
17+ assert . strictEqual ( err , _err ) ;
1718 } ) ) ;
1819 writable . write ( 'asd' ) ;
1920 writable . end ( common . mustCall ( ( err ) => {
20- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
21+ assert . strictEqual ( err , _err ) ;
2122 } ) ) ;
2223 writable . end ( common . mustCall ( ( err ) => {
23- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
24+ assert . strictEqual ( err , _err ) ;
2425 } ) ) ;
2526}
2627
@@ -57,18 +58,12 @@ const stream = require('stream');
5758 }
5859 } ) ;
5960 w . end ( 'testing ended state' , common . mustCall ( ( err ) => {
60- // This errors since .destroy(err), which is invoked by errors
61- // in same tick below, will error all pending callbacks.
62- // Does this make sense? Not sure.
63- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
61+ assert . strictEqual ( err . code , 'ERR_STREAM_WRITE_AFTER_END' ) ;
6462 } ) ) ;
6563 assert . strictEqual ( w . destroyed , false ) ;
6664 assert . strictEqual ( w . writableEnded , true ) ;
6765 w . end ( common . mustCall ( ( err ) => {
68- // This errors since .destroy(err), which is invoked by errors
69- // in same tick below, will error all pending callbacks.
70- // Does this make sense? Not sure.
71- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
66+ assert . strictEqual ( err . code , 'ERR_STREAM_WRITE_AFTER_END' ) ;
7267 } ) ) ;
7368 assert . strictEqual ( w . destroyed , false ) ;
7469 assert . strictEqual ( w . writableEnded , true ) ;
0 commit comments