-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: check EADDRINUSE after binding localPort #15097
Conversation
What should the semver-iness of this be? |
const net = require('net'); | ||
|
||
const server1 = net.createServer(common.mustNotCall()); | ||
server1.listen(common.PORT, '127.0.0.1', common.mustCall(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid using common.PORT
? If not I think it's better to move this test to sequential.
@@ -0,0 +1,26 @@ | |||
'use strict'; | |||
|
|||
// This tests that net.connect() from a used local port throws EADDRINUSE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It makes me happy to see a new test with a description.
const net = require('net'); | ||
|
||
const server1 = net.createServer(common.mustNotCall()); | ||
server1.listen(common.PORT, '127.0.0.1', common.mustCall(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use common.localhostIPv4
const server2 = net.createServer(common.mustNotCall()); | ||
server2.listen(common.PORT + 1, '127.0.0.1', common.mustCall(() => { | ||
const client = net.connect({ | ||
host: server1.address().address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common.localhostIPv4
here as well because of #14900
const server1 = net.createServer(common.mustNotCall()); | ||
server1.listen(common.PORT, '127.0.0.1', common.mustCall(() => { | ||
const server2 = net.createServer(common.mustNotCall()); | ||
server2.listen(common.PORT + 1, '127.0.0.1', common.mustCall(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're doing common.PORT + 1
this test should be in /test/sequential
Tricky one... but IMHO |
c3c94cd
to
c9c55ef
Compare
@lpinca @refack Thanks for the review. Updated, PTAL. New CI: https://ci.nodejs.org/job/node-test-pull-request/9897/ |
@jasnell I would say it's a patch since it never worked anyway...to me depending on the "bind to that port if available, otherwise bind to a random port" behavior seems like a bug. |
@joyeecheung I've added a commit that uses |
@refack Ah, makes sense to me, sorry that I overlooked #15097 (comment) . New CI: https://ci.nodejs.org/job/node-test-pull-request/9898/ |
PR-URL: nodejs#15097 Fixes: nodejs#15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in c419adf |
PR-URL: nodejs/node#15097 Fixes: nodejs/node#15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This is not landing cleanly on v8.x. @joyeecheung would you be willing to backport to v8.x-staging |
PR-URL: nodejs#15097 Fixes: nodejs#15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@MylesBorins Backport opened at #15309 |
PR-URL: #15097 Fixes: #15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #15097 Fixes: #15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #15097 Fixes: #15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #15097 Fixes: #15084 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Should this be backported to |
Depends on #11796 which is don't-land-on-v6.x |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesFixes: #15084
See the comments of
checkBindError
for details.Affected core subsystem(s)
net, test