Skip to content

Commit

Permalink
stream: forward errored to callback
Browse files Browse the repository at this point in the history
Refs: #39356
  • Loading branch information
ronag committed Jul 12, 2021
1 parent de85b1e commit 67ca62a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ function errorBuffer(state) {
const { chunk, callback } = state.buffered[n];
const len = state.objectMode ? 1 : chunk.length;
state.length -= len;
callback(new ERR_STREAM_DESTROYED('write'));
callback(state.errored ?? new ERR_STREAM_DESTROYED('write'));
}

const onfinishCallbacks = state[kOnFinished].splice(0);
for (let i = 0; i < onfinishCallbacks.length; i++) {
onfinishCallbacks[i](new ERR_STREAM_DESTROYED('end'));
onfinishCallbacks[i](state.errored ?? new ERR_STREAM_DESTROYED('end'));
}

resetBuffer(state);
Expand Down

0 comments on commit 67ca62a

Please sign in to comment.