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

net: support passing undefined to listen() #14234

Closed

Conversation

sam-github
Copy link
Contributor

For consistency with 4.x and 8.x.

This commit also contains a forward port of
#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

Ref: #14205

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)

@nodejs-github-bot nodejs-github-bot added net Issues and PRs related to the net subsystem. v6.x labels Jul 14, 2017
@sam-github
Copy link
Contributor Author

@cjihrig What was happening is that assertPort() explicitly allows undefined as a valid value. However, toNumber() did not, and was converting undefined to false, and that then got passed to assertPort(), and threw. I think I fixed this in the right place, but perhaps you have other suggestions.

@sam-github
Copy link
Contributor Author

@nodejs/lts PTAL, this is the LTS part of the fix for #14205

-1 / 0,
].forEach(function(port) {
assert.throws(function() {
net.Server().listen({ port: port }, common.fail);
Copy link
Member

@lpinca lpinca Jul 14, 2017

Choose a reason for hiding this comment

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

This first argument should be port not an object.


net.Server().listen(true).on('error', common.mustCall(function(err) {
assert.strictEqual(err.code, 'EACCES');
}));
Copy link
Member

Choose a reason for hiding this comment

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

fwiw, this can be simplified to ....

net.Server().listen(true).on('error', common.expectsError({ code: 'EACCES' }));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expectsError doesn't exist on 6.x, AFAICT

Copy link
Member

Choose a reason for hiding this comment

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

ah! heh... good point ;-)

@sam-github
Copy link
Contributor Author

sam-github commented Jul 17, 2017

@nodejs/lts PTAL

@sam-github
Copy link
Contributor Author

@gibfahn
Copy link
Member

gibfahn commented Jul 18, 2017

@sam-github is this semver-minor? I guess if it restores previous behaviour that was then broken it's a bugfix.

@MylesBorins
Copy link
Contributor

Waiting on confirmation if this is a bugfix or not. It will likely not make the v6.11.2-rc today, but willing to roll it into the next rc later this week if it is indeed a patch

@sam-github
Copy link
Contributor Author

@MylesBorins This is a bug fix, see #14205 (comment), undefined could be passed in 4.x and 8.x, but can't in 6.x.

I want to land, but do I need one approval, or two? @cjihrig is the domain expert here and approved it, maybe his LGTM is all I need?

@jasnell
Copy link
Member

jasnell commented Jul 19, 2017

I agree with bug fix.

sam-github added a commit that referenced this pull request Jul 21, 2017
For consistency with 4.x and 8.x.

This commit also contains a forward port of
#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

PR-URL: #14234
Refs: #14205
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@sam-github
Copy link
Contributor Author

Landed in 0b17a45

@sam-github sam-github closed this Jul 21, 2017
@sam-github sam-github deleted the fix-listen-on-undefined branch July 21, 2017 16:06
MylesBorins pushed a commit that referenced this pull request Jul 21, 2017
For consistency with 4.x and 8.x.

This commit also contains a forward port of
#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

PR-URL: #14234
Refs: #14205
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 21, 2017
@MylesBorins
Copy link
Contributor

MylesBorins commented Jul 31, 2017

@sam-github This seems to be breaking windows CI so I'm backing it out of v6.11.2 for now

https://ci.nodejs.org/job/node-test-binary-windows/10189/RUN_SUBSET=0,VS_VERSION=vcbt2015,label=win10/

edit: for clarity I'm keeping it on staging for now, please let me know if you can figure out why we are getting time outs

MylesBorins pushed a commit that referenced this pull request Aug 1, 2017
For consistency with 4.x and 8.x.

This commit also contains a forward port of
#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

PR-URL: #14234
Refs: #14205
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@MylesBorins
Copy link
Contributor

MylesBorins commented Aug 12, 2017

I'm backing this out of staging as the broken test is blocking CI on other PRS.

@sam-github please reopen, rebase, and try to get this passing on windows.

edit: here is a gist of the patch as you may have deleted the branch and links above could be removed in cache flush

https://gist.github.com/MylesBorins/f5ab7d9a23126c13c36ead9b2fa64f92

@MylesBorins
Copy link
Contributor

ping @sam-github just a reminder this got backed out. I can't reopen this as you deleted your branch

@sam-github sam-github restored the fix-listen-on-undefined branch August 16, 2017 19:21
@sam-github
Copy link
Contributor Author

@MylesBorins restored branch, won't have time to look more at it until I'm back from vacation

@MylesBorins MylesBorins reopened this Aug 16, 2017
@MylesBorins MylesBorins force-pushed the v6.x-staging branch 2 times, most recently from aaf4e13 to 31f572c Compare September 5, 2017 16:50
@BridgeAR BridgeAR added the wip Issues and PRs that are still a work in progress. label Sep 13, 2017
@MylesBorins
Copy link
Contributor

@nodejs/lts thoughts?

@jasnell
Copy link
Member

jasnell commented Sep 19, 2017

Thoughts on what exactly? The test is still failing on Windows, correct? I'm good with this landing once that it resolved.

@sam-github sam-github force-pushed the fix-listen-on-undefined branch 2 times, most recently from 39c381c to 8c25a95 Compare September 19, 2017 16:20
@sam-github
Copy link
Contributor Author

I'm baffled that this has windows specific behaviour, and I'm looking into it.

starting with re-running ci: https://ci.nodejs.org/job/node-test-pull-request/10136/

@sam-github
Copy link
Contributor Author

I figured this out, it's because net.Server().listen(1) works on Windows. I'll fix the test.

@sam-github
Copy link
Contributor Author

For consistency with 4.x and 8.x.

This commit also contains a forward port of
nodejs#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

PR-URL: nodejs#14234
Refs: nodejs#14205
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@sam-github
Copy link
Contributor Author

@MylesBorins last ci passed except for lint (fixed) and arm (probably broken), this should pass:

ci: https://ci.nodejs.org/job/node-test-pull-request/10148/

@MylesBorins
Copy link
Contributor

MylesBorins commented Sep 20, 2017

landed in caeee38

MylesBorins pushed a commit that referenced this pull request Sep 20, 2017
For consistency with 4.x and 8.x.

This commit also contains a forward port of
#14232 to confirm that 4.x and 6.x
behave identically with respect to the port argument.

Backport-PR-URL: #14234
PR-URL: #14234
Refs: #14205
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@sam-github sam-github deleted the fix-listen-on-undefined branch September 20, 2017 15:42
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
@MylesBorins
Copy link
Contributor

@cjihrig should we hold off on landing this until the bugs are all fixed in 8.x?

@cjihrig
Copy link
Contributor

cjihrig commented Sep 22, 2017

Just reiterating from IRC. I believe this should stay in the release if everything is passing. The bugs on 8.x in question are slightly different (#14205 (comment)).

MylesBorins added a commit that referenced this pull request Oct 3, 2017
Notable Changes:

* net:
  - support passing undefined to listen() to match behavior in v4.x
    and v8.x (Sam Roberts)
    #14234

PR-URL: #15506
MylesBorins added a commit that referenced this pull request Oct 3, 2017
Notable Changes:

* net:
  - support passing undefined to listen() to match behavior in v4.x
    and v8.x (Sam Roberts)
    #14234

PR-URL: #15506
addaleax pushed a commit to addaleax/ayo that referenced this pull request Oct 4, 2017
Notable Changes:

* net:
  - support passing undefined to listen() to match behavior in v4.x
    and v8.x (Sam Roberts)
    nodejs/node#14234

PR-URL: nodejs/node#15506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants