@@ -8,19 +8,20 @@ const stream = require('stream');
8
8
// Invoke end callback on failure.
9
9
const writable = new stream . Writable ( ) ;
10
10
11
+ const _err = new Error ( 'kaboom' ) ;
11
12
writable . _write = ( chunk , encoding , cb ) => {
12
- process . nextTick ( cb , new Error ( 'kaboom' ) ) ;
13
+ process . nextTick ( cb , _err ) ;
13
14
} ;
14
15
15
16
writable . on ( 'error' , common . mustCall ( ( err ) => {
16
- assert . strictEqual ( err . message , 'kaboom' ) ;
17
+ assert . strictEqual ( err , _err ) ;
17
18
} ) ) ;
18
19
writable . write ( 'asd' ) ;
19
20
writable . end ( common . mustCall ( ( err ) => {
20
- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
21
+ assert . strictEqual ( err , _err ) ;
21
22
} ) ) ;
22
23
writable . end ( common . mustCall ( ( err ) => {
23
- assert . strictEqual ( err . code , 'ERR_STREAM_DESTROYED' ) ;
24
+ assert . strictEqual ( err , _err ) ;
24
25
} ) ) ;
25
26
}
26
27
@@ -57,18 +58,12 @@ const stream = require('stream');
57
58
}
58
59
} ) ;
59
60
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' ) ;
64
62
} ) ) ;
65
63
assert . strictEqual ( w . destroyed , false ) ;
66
64
assert . strictEqual ( w . writableEnded , true ) ;
67
65
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' ) ;
72
67
} ) ) ;
73
68
assert . strictEqual ( w . destroyed , false ) ;
74
69
assert . strictEqual ( w . writableEnded , true ) ;
0 commit comments