File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -83,20 +83,18 @@ function onWriteComplete(status) {
8383
8484 const stream = this . handle [ owner_symbol ] ;
8585
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 ) ;
9093 }
9194
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 ) {
9696 if ( typeof this . callback === 'function' )
97- this . callback ( ex ) ;
98- else
99- stream . destroy ( ex ) ;
97+ this . callback ( null ) ;
10098 return ;
10199 }
102100
You can’t perform that action at this time.
0 commit comments