Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stream: consistent clearBuffer
  • Loading branch information
ronag committed Aug 20, 2019
commit 4df3c3ee6149d0bd05340cae749b0d2fe82ea604
13 changes: 7 additions & 6 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ Writable.prototype.uncork = function() {
if (state.corked) {
state.corked--;

if (!state.writing &&
if (!state.destroyed &&
!state.writing &&
!state.corked &&
!state.bufferProcessing &&
state.bufferedRequest)
Expand Down Expand Up @@ -468,16 +469,16 @@ function onwrite(stream, er) {
if (er)
onwriteError(stream, state, sync, er, cb);
else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state) || stream.destroyed;

if (!finished &&
if (!state.destroyed &&
!state.writing &&
!state.corked &&
!state.bufferProcessing &&
state.bufferedRequest) {
state.bufferedRequest)
clearBuffer(stream, state);
}

// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state);
if (sync) {
process.nextTick(afterWrite, stream, state, cb);
} else {
Expand Down