Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: eos use writableFinished when available #28749

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Jul 18, 2019

Use writableFinished when available. Improves compat with streamlike objects.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@@ -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.

@nodejs-github-bot
Copy link
Collaborator

@trivikr trivikr added the stream Issues and PRs related to the stream subsystem. label Jul 21, 2019
@nodejs-github-bot
Copy link
Collaborator

Trott
Trott previously approved these changes Jul 21, 2019
@Trott Trott dismissed their stale review July 21, 2019 05:11

thinking about this some more, probably could use a test?

@Trott
Copy link
Member

Trott commented Jul 21, 2019

Would it be not-too-onerous to add a test that would fail on master but pass with this change?

@Trott
Copy link
Member

Trott commented Jul 22, 2019

/ping @ronag Are you interested in adding a test to this?

@ronag
Copy link
Member Author

ronag commented Aug 28, 2019

This is covered by #28748

@ronag ronag closed this Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants