Skip to content

Commit

Permalink
stream: delete redundant code
Browse files Browse the repository at this point in the history
In `Writable.prototype.end()`, `state.ending` is true after calling
`endWritable()` and it doesn't reset to false.

In `Writable.prototype.uncork()`, `state.finished` must be false
if `state.bufferedRequest` is true.

PR-URL: #18145
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
陈刚 authored and mcollina committed Feb 2, 2018
1 parent caa26cb commit ce83099
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ Writable.prototype.uncork = function() {

if (!state.writing &&
!state.corked &&
!state.finished &&
!state.bufferProcessing &&
state.bufferedRequest)
clearBuffer(this, state);
Expand Down Expand Up @@ -569,7 +568,7 @@ Writable.prototype.end = function(chunk, encoding, cb) {
}

// ignore unnecessary end() calls.
if (!state.ending && !state.finished)
if (!state.ending)
endWritable(this, state, cb);

This comment has been minimized.

Copy link
@chdh

chdh Jul 28, 2018

Contributor
else
   if (cb)   
      process.nextTick(cb);

Shouldn't the callback be called here, if state.ending is true?

This comment has been minimized.

Copy link
@mcollina

mcollina Jul 28, 2018

Member

I thought this change was correct. Can you please provide an example where the current logic fails?

This comment has been minimized.

Copy link
@chdh

chdh Jul 28, 2018

Contributor

It's not the fault of this change, but when Writable.end() is called with a callback (cb parameter) and state.ending is already set, the callback is never called. This is obvious when you look at the whole code in Writable.end().

This comment has been minimized.

Copy link
@mcollina

mcollina Jul 28, 2018

Member

That as always be the case, unfortunately.

};

Expand Down

0 comments on commit ce83099

Please sign in to comment.