File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const {
45
45
getHighWaterMark,
46
46
getDefaultHighWaterMark
47
47
} = require ( 'internal/streams/state' ) ;
48
+ const assert = require ( 'internal/assert' ) ;
48
49
const {
49
50
ERR_INVALID_ARG_TYPE ,
50
51
ERR_METHOD_NOT_IMPLEMENTED ,
@@ -826,9 +827,16 @@ ObjectDefineProperties(Writable.prototype, {
826
827
const destroy = destroyImpl . destroy ;
827
828
Writable . prototype . destroy = function ( err , cb ) {
828
829
const state = this . _writableState ;
829
- if ( ! state . destroyed ) {
830
+
831
+ // Invoke pending callbacks.
832
+ if (
833
+ state . bufferedIndex < state . buffered . length ||
834
+ state [ kOnFinished ] . length
835
+ ) {
836
+ assert ( ! state . destroyed ) ;
830
837
process . nextTick ( errorBuffer , state ) ;
831
838
}
839
+
832
840
destroy . call ( this , err , cb ) ;
833
841
return this ;
834
842
} ;
You can’t perform that action at this time.
0 commit comments