Skip to content
Closed
Changes from all commits
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
3 changes: 2 additions & 1 deletion lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function eos(stream, opts, callback) {
if (!stream.writable) onfinish();
};

var writableEnded = stream._writableState && stream._writableState.finished;
var writableEnded = stream.writableFinished ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of these new getters is to avoid using {_readable,_writable}State but in this case if the getter exists and returns false we use _writableState twice (first time in the getter itself and second time in the RHS of the "or" condition) so I'm not a fan of this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you think V8 is able to figure that out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, I don't know.

Copy link
Member

@Trott Trott Jul 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a desire to use writableFinished instead of _writableState in files such as this one, that are internal to streams, or should we only be doing that outside of the streams module itself (for example, in lib/http.js).

I thought the answer was "Only in files outside of the streams module itself."

The answer is relevant to determining how much work remains to be done to close what is literally the oldest open issue we have: #445.

Copy link
Member

@Trott Trott Jul 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait, I see there's the "Improves compat with streamlike objects." comment, so the motivation isn't expanding usage of writableFinished for its own sake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I also missed that. It makes more sense now, approving.

(stream._writableState && stream._writableState.finished);
const onfinish = () => {
writable = false;
writableEnded = true;
Expand Down