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, http, http2: make all stream.end() call return this #18780

Closed
wants to merge 3 commits into from

Conversation

@mcollina
Copy link
Member

mcollina commented Feb 14, 2018

This PR make all the instances of stream.end() return this. This includes both http and http2 pseudo-writables.

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
Affected core subsystem(s)

stream, http, http2

@mcollina mcollina requested a review from addaleax Feb 14, 2018

@mcollina

This comment has been minimized.

Copy link
Member Author

mcollina commented Feb 14, 2018

@mscdex

This comment has been minimized.

Copy link
Contributor

mscdex commented Feb 14, 2018

Can this change in return type really be justified?

Also:

  • an early return is missed in OutgoingMessage.end()
  • shouldn't this be semver-major because of the change in return type?
@benjamingr

This comment has been minimized.

Copy link
Member

benjamingr commented Feb 14, 2018

@mcollina I'm guessing we missed some context - any reading material about this change or some rationale?

@jasnell

This comment has been minimized.

Copy link
Member

jasnell commented Feb 14, 2018

Adding a return type where there was previously not one should not be semver-major as it shouldn't break any prior assumptions.

@benjamingr

This comment has been minimized.

Copy link
Member

benjamingr commented Feb 14, 2018

@jasnell uhh.. I think it can break assumptions?

I've seen return somethingThatReturnsUndefined() in JavaScript quite a few times in order to avoid doing somethingThatReturnsUndefined(); return; in two lines. I don't like it, but it's definitely there - and this isn't a change in an experimental library - it's core HTTP which everyone builds on.

@jasnell

This comment has been minimized.

Copy link
Member

jasnell commented Feb 14, 2018

Bleh, ok. Major it is then.

@mcollina

This comment has been minimized.

Copy link
Member Author

mcollina commented Feb 14, 2018

I forgot to put the label on it, the intention is it to be semver-major.

Basically this cleans up the situation for .end() in streams. Currently we have net and tls that return this, the stream module that returns undefined, and http that return whatever _send() returns. I thought that the least disruptive change would be to have it return this everywhere.

@benjamingr
Copy link
Member

benjamingr left a comment

Thanks, that explains it and this does bring consistency. Actual code LGTM

@mcollina mcollina force-pushed the mcollina:end-this branch from 69ac34e to cc5937c Feb 15, 2018

@lpinca

lpinca approved these changes Feb 15, 2018

changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `http.ClientRequest`.

This comment has been minimized.

@lpinca

lpinca Feb 15, 2018

Member

Nit: how about using just ClientRequest to be consistent with the other comments?

This comment has been minimized.

@mcollina

mcollina Feb 16, 2018

Author Member

Done.

@mcollina mcollina force-pushed the mcollina:end-this branch from cc5937c to 54facaa Feb 16, 2018

@mcollina

This comment has been minimized.

Copy link
Member Author

mcollina commented Feb 16, 2018

@mscdex are you ok with this change then?

@BridgeAR

This comment has been minimized.

@mcollina

This comment has been minimized.

Copy link
Member Author

mcollina commented Feb 19, 2018

Landed as f6721c2, 8118da7 and 3d93f39.

@mcollina mcollina closed this Feb 19, 2018

@mcollina mcollina deleted the mcollina:end-this branch Feb 19, 2018

mcollina added a commit that referenced this pull request Feb 19, 2018

stream: writable.end should return this.
PR-URL: #18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

mcollina added a commit that referenced this pull request Feb 19, 2018

http: OutgoingMessage.end() should return this
PR-URL: #18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

mcollina added a commit that referenced this pull request Feb 19, 2018

http2: make response.end() return this
PR-URL: #18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@benjamingr

This comment has been minimized.

Copy link
Member

benjamingr commented Feb 19, 2018

Awesome work, adding "don't land on" tags.

MayaLekova added a commit to MayaLekova/node that referenced this pull request May 8, 2018

stream: writable.end should return this.
PR-URL: nodejs#18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

MayaLekova added a commit to MayaLekova/node that referenced this pull request May 8, 2018

http: OutgoingMessage.end() should return this
PR-URL: nodejs#18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

MayaLekova added a commit to MayaLekova/node that referenced this pull request May 8, 2018

http2: make response.end() return this
PR-URL: nodejs#18780
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.