-
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
test: avoid connecting to :: in test-net-timeout #7781
Conversation
@bnoordhuis c.f. #7728 (comment)
This test does currently connect to |
if (common.hasIPv6) | ||
var host = '::1'; | ||
else | ||
var host = '127.0.0.1'; |
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 you either use common.localhostIPv4
here or (more succinctly) make the server listen on that 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.
@bnoordhuis do you want
var host = common.localhostIPv4
else
var host = common.localhostIPv6
or should we just only use IPv4 here?
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.
My preference is for this:
diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js
index 2645ccc..c050ddb 100644
--- a/test/gc/test-net-timeout.js
+++ b/test/gc/test-net-timeout.js
@@ -29,7 +29,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = net.createServer(serverHandler);
-server.listen(0, getall);
+server.listen(0, common.localhostIPv4, getall);
function getall() {
if (count >= todo)
BTW, there is no common.localhostIPv6
.
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.
Tried this, failing with TypeError: Cannot read property 'port' of null
diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js
index 2645ccc..d129bd0 100644
--- a/test/gc/test-net-timeout.js
+++ b/test/gc/test-net-timeout.js
@@ -19,7 +19,7 @@ function serverHandler(sock) {
const net = require('net');
const weak = require('weak');
-require('../common');
+const common = require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;
@@ -29,7 +29,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = net.createServer(serverHandler);
-server.listen(0, getall);
+server.listen(0, common.localhostIPv4, getall);
function getall() {
if (count >= todo)
EDIT: how do you get syntax highlighting on diffs? ```diff, worked it out
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.
@bnoordhuis also do we need to specify a port (i.e. server.listen(common.PORT, common.localhostIPv4, getall);
)?
/tmp/gib/node/test/gc/test-net-timeout.js:38
const req = net.connect(server.address().port, server.address().address);
^
TypeError: Cannot read property 'port' of null
at getall (/tmp/gib/node/test/gc/test-net-timeout.js:38:43)
Left a comment. I wonder, is this the only test with that problem? |
@@ -35,7 +35,11 @@ function getall() { | |||
if (count >= todo) | |||
return; | |||
|
|||
const req = net.connect(server.address().port, server.address().address); | |||
if (common.hasIPv6) | |||
var host = '::1'; |
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.
Indentation is not right. Also, if we are doing this ternary operator is okay I guess
@@ -19,7 +19,7 @@ function serverHandler(sock) { | |||
|
|||
const net = require('net'); | |||
const weak = require('weak'); | |||
require('../common'); | |||
const common = require('../common'); |
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 touching this line, it might be worthwhile to move it to the top of the file.
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.
Okay, will do. EDIT: done
This test tries to connect to :: or 0.0.0.0, which resolves to localhost on some platforms but not others. Change to specify localhost.
22741e4
to
02c7991
Compare
@Trott I don't think the |
@gibfahn You're right. The only useful part of the CI run for this is the linter. :-| |
Thanks @Trott , unfortunately the test is still failing for me with: const req = net.connect(server.address().port, server.address().address);
^
TypeError: Cannot read property 'port' of null
at getall (C:\Users\gib\node\test\gc\test-net-timeout.js:39:43)
at Object.<anonymous> (C:\Users\gib\node\test\gc\test-net-timeout.js:54:3) |
@gibfahn The /cc (based on line counts in git blame, not the best approach, but hopefully not the worst either) @isaacs @cjihrig @targos @piscisaureus @tjfontaine @nodejs/testing |
c133999
to
83c7a88
Compare
Fixed by #10854 |
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
Fixes #7291
This test tries to connect to :: or 0.0.0.0, which resolves to localhost
on some platforms but not others. Change to specify localhost.
@quaidn I basically did what you suggested in #7291 (comment), but used
common.hasIPv6
instead.@cjihrig I don't think this will make a difference to the changes you made to
gc/test-net-timeout.js
a few days ago, but I'd appreciate a check.cc @Trott
EDIT: I would have replaced
server.address().address
with'localhost'
, but until #7288 is resolved that can cause problems on some machines.EDIT 2: Actually you can use
localhost
, as if you don't specify IPv4 or IPv6localhost
should resolve to127.0.0.1
if::1
isn't defined.