Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Sep 5, 2020
1 parent 6734876 commit ab7b73d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const {
getHighWaterMark,
getDefaultHighWaterMark
} = require('internal/streams/state');
const assert = require('assert');
const {
ERR_INVALID_ARG_TYPE,
ERR_METHOD_NOT_IMPLEMENTED,
Expand Down Expand Up @@ -826,12 +827,16 @@ ObjectDefineProperties(Writable.prototype, {
const destroy = destroyImpl.destroy;
Writable.prototype.destroy = function(err, cb) {
const state = this._writableState;

// Invoke pending callbacks.
if (
!state.destroyed &&
(state.bufferedIndex < state.buffered.length || state[kOnFinished].length)
state.bufferedIndex < state.buffered.length ||
state[kOnFinished].length
) {
assert(!state.destroyed);
process.nextTick(errorBuffer, state);
}

destroy.call(this, err, cb);
return this;
};
Expand Down

0 comments on commit ab7b73d

Please sign in to comment.