Uh oh!
There was an error while loading. Please reload this page.
stream: delete redundant code - #18145
Conversation
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.
`state.corkedRequestsFree` of a writable stream is always not null.
mcollina
left a comment
There was a problem hiding this comment.
Thanks for contributing! I've left some questions/notes around the PR.
| } | ||
| // reuse the free corkReq. | ||
| state.corkedRequestsFree.next = corkReq; |
There was a problem hiding this comment.
Unfortunately, this can end up being null because it copied over in: https://github.com/MoonBall/node/blob/dd13a79b830ef2d33ac0288e197a431a63e40941/lib/_stream_writable.js#L517. Can you revert this?
There was a problem hiding this comment.
if (holder.next) can ensure that state.corkedRequestsFree is not null.
| // ignore unnecessary end() calls. | ||
| if (!state.ending && !state.finished) | ||
| if (!state.ending) |
There was a problem hiding this comment.
This is actually a behavior change. Can you add a unit test?
There was a problem hiding this comment.
state.finished = true is only in finishMaybe(). If we simplify the finishMaybe(), it should be:
function finishMaybe(stream, state) {
if (state.ending) {
state.finished = true;
}
}
And, state.ending doesn't set to false.
So:
- if
state.finishedis true,state.endingmust be true:!state.ending && !state.finishedequalsfalse && false.!state.endingequalsfalse.!state.ending && !state.finishedequals!state.ending. - if
state.finishedis false:!state.ending && !state.finishedequals!state.ending && true.!state.ending && !state.finishedequals!state.ending.
| if (!state.writing && | ||
| !state.corked && | ||
| !state.finished && |
There was a problem hiding this comment.
state.finished should equal false if state.bufferedRequest isn't null.
mcollina
commented
Jan 17, 2018
BridgeAR
commented
Feb 1, 2018
@mcollina PTAL |
mcollina
commented
Feb 1, 2018
mcollina
commented
Feb 2, 2018
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins
commented
Mar 20, 2018
Should this land on LTS? It lands cleanly on 8.x, but will require a backport for 6.x |
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: nodejs#18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: nodejs#18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins
commented
May 23, 2018
I've landed on 8.x @nodejs/streams @mcollina please lmk if it should be backed out |
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
mcollina
commented
May 23, 2018
This can be backported. |
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In
Writable.prototype.end(),state.endingis true after callingendWritable()and it doesn't reset to false.In
Writable.prototype.uncork(),state.finishedmust be falseif
state.bufferedRequestis true.In
onCorkedFinish(),state.corkedRequestsFreeof a writablestream is never null.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
stream