File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -83,20 +83,18 @@ function onWriteComplete(status) {
83
83
84
84
const stream = this . handle [ owner_symbol ] ;
85
85
86
- if ( stream . destroyed ) {
87
- if ( typeof this . callback === 'function' )
88
- this . callback ( null ) ;
89
- return ;
86
+ if ( status < 0 ) {
87
+ const error = new ErrnoException ( status , 'write' , this . error ) ;
88
+ if ( typeof this . callback === 'function' ) {
89
+ return this . callback ( error ) ;
90
+ }
91
+
92
+ return stream . destroy ( error ) ;
90
93
}
91
94
92
- // TODO (ronag): This should be moved before if(stream.destroyed)
93
- // in order to avoid swallowing error.
94
- if ( status < 0 ) {
95
- const ex = new ErrnoException ( status , 'write' , this . error ) ;
95
+ if ( stream . destroyed ) {
96
96
if ( typeof this . callback === 'function' )
97
- this . callback ( ex ) ;
98
- else
99
- stream . destroy ( ex ) ;
97
+ this . callback ( null ) ;
100
98
return ;
101
99
}
102
100
You can’t perform that action at this time.
0 commit comments