-
Notifications
You must be signed in to change notification settings - Fork 30k
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: fix test-net-* error code check for getaddrinfo(3) #5099
Conversation
You've actually had these tests fail on Alpine Linux or whatever? It's my impression that the (unfortunate) Lines 19 to 20 in 4897f94
|
Yes, this test failed: Path: parallel/test-net-connect-immediate-finish
assert.js:89
throw new assert.AssertionError({
^
AssertionError: 'EAI_AGAIN' === 'ENOTFOUND'
at Socket.<anonymous> (/home/ncopa/src/node/test/parallel/test-net-connect-immediate-finish.js:14:10)
at Socket.<anonymous> (/home/ncopa/src/node/test/common.js:395:15)
at Socket.g (events.js:277:16)
at emitOne (events.js:91:13)
at Socket.emit (events.js:183:7)
at connectErrorNT (net.js:990:8)
at nextTickCallbackWith2Args (node.js:484:9)
at process._tickCallback (node.js:398:17) |
I suppose this is a better fix then: diff --git a/lib/dns.js b/lib/dns.js
index bcf6aae..c139a78 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -20,6 +20,7 @@ function errnoException(err, syscall, hostname) {
// the true error to the user. ENOTFOUND is not even a proper POSIX error!
if (err === uv.UV_EAI_MEMORY ||
err === uv.UV_EAI_NODATA ||
+ err === uv.UV_EAI_AGAIN ||
err === uv.UV_EAI_NONAME) {
err = 'ENOTFOUND';
} It makes both tests pass. But as the comment there says, it should probably return the real error instead of inject ENOTFOUND. |
Agreed. That change would be |
37808f0
to
79e7919
Compare
Return the real system error to user insetad of injecting 'ENOTFOUND' which is not a proper POSIX error. nodejs#5099 (comment) Also fix the test suite to check for the corresponding error message. The hostname '...' was replaced with '***' because '...' returns inconsistent error message on different system. On GNU libc it intantly returns EAI_NONAME but on musl libc it returns EAI_AGAIN after a timeout.
7da4fd4
to
c7066fb
Compare
What prevents this from being merged? |
If possible, this could use a test for the code change that is not dependent on the operating system. Since we don't run Alpine Linux in CI (continuous integration), it means that someone could change the code to break it again and we'd never know. Required: At least one collaborator knowledgable enough about the It also needs a CI run. Any collaborator giving an LGTM can do that. |
Commit messages should usually be a little more definitive. ;-) For testing take a look at |
+1 to getting rid of it. |
I agree, let's get rid of it. |
@trevnorris @bnoordhuis getting rid of the node specific error message is handled in separate PR, #5196 where it is said that we should deprecate it in v6 and remove it in v7. #5196 (comment) |
#5196 has already been marked as semver major. You could argue that this is semver major too though. I wonder if we could combine the two by adding the check from this PR and starting the deprecation process. |
ok. I agree that it is better to fix it properly instead of adding more mess. How about we change the testcase: diff --git a/test/parallel/test-net-connect-immediate-finish.js b/test/parallel/test-net-connect-immediate-finish.js
index a540373..6114233 100644
--- a/test/parallel/test-net-connect-immediate-finish.js
+++ b/test/parallel/test-net-connect-immediate-finish.js
@@ -3,14 +3,14 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
-const client = net.connect({host: '...', port: common.PORT});
+const client = net.connect({host: '***', port: common.PORT});
client.once('error', common.mustCall(function(err) {
assert(err);
assert.strictEqual(err.code, err.errno);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.strictEqual(err.host, err.hostname);
- assert.strictEqual(err.host, '...');
+ assert.strictEqual(err.host, '***');
assert.strictEqual(err.syscall, 'getaddrinfo');
})); This is also a completely invalid hostname, but it will give same error (EAI_NONAME) on the different platforms. (I have tested musl libc, gnu libc and osx) |
8dcdfdd
to
78d9224
Compare
Replace '...' as invalid hostname with '***', which will give a more consisten error message on different systems. The hostname '...' returns EAI_AGAIN on musl libc and EAI_NONAME on most other systems. By changing the testcase we get same restult on all known platforms.
78d9224
to
519793d
Compare
I rebased the patch and changed the testcase instead. Using '***' as invalid hostname goes around the entire problem and we can let the ugly node specific error message alone.
|
@ncopa |
@trevnorris that is what my original patch did (#5099 (comment)) but the discussion went in a loop and people are too scared to touch the trying to resolve the invalid hostname The |
If I understand correctly, the situation is this:
Sooooooo..... our options here are:
Among the options, I think the one taken in this PR is the best. LGTM, but I'd like to get a validating LGTM from someone who has worked more with the DNS code (which is why I originally looped in @bnoordhuis, @cjihrig, and @trevnorris). |
@Trott Thank you for a nice summary. I think you completely understand.
This was my original approach, and I agree. I don't like this either.
Correct. It is by far less risky to use another invalid hostname that gives expected result everywhere. I will try to also fix this in musl libc, because it does not really make sense to try again on the invalid hostname |
We have Alpine in CI at the moment (won't stay if we can't get this sorted out), the EAI_AGAIN errors are the only ones left standing: https://ci.nodejs.org/job/node-test-commit-linux/3804/nodes=ubuntu1604_docker_alpine34-64 |
@rvagg can you cherry-pick this commit and double check everything passes? |
only one failure https://ci.nodejs.org/job/node-test-commit/3747/ and that was thanks to Jenkins. |
I'm going to lgtm this, it's not very invasive and the logic is sound as far as I'm concerned. |
Replace '...' as invalid hostname with '***', which will give a more consisten error message on different systems. The hostname '...' returns EAI_AGAIN on musl libc and EAI_NONAME on most other systems. By changing the testcase we get same restult on all known platforms. PR-URL: #5099 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
needed for fixing dns tests in nodejs test suite nodejs/node#5099
Replace '...' as invalid hostname with '***', which will give a more consisten error message on different systems. The hostname '...' returns EAI_AGAIN on musl libc and EAI_NONAME on most other systems. By changing the testcase we get same restult on all known platforms. PR-URL: #5099 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
needed for fixing dns tests in nodejs test suite nodejs/node#5099 fixes #5725 (cherry picked from commit c0bd1e4)
Replace '...' as invalid hostname with '***', which will give a more consisten error message on different systems. The hostname '...' returns EAI_AGAIN on musl libc and EAI_NONAME on most other systems. By changing the testcase we get same restult on all known platforms. PR-URL: #5099 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
just backported, aiming to have it in 4.4.7 |
Replace '...' as invalid hostname with '***', which will give a more consisten error message on different systems. The hostname '...' returns EAI_AGAIN on musl libc and EAI_NONAME on most other systems. By changing the testcase we get same restult on all known platforms. PR-URL: #5099 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Heh – looks like @ncopa fixed it in Alpine (3.4.1) too: http://bugs.alpinelinux.org/issues/5725 👍 |
So it would appear that backporting this to v4.4.7 has cause some serious weirdness for local testing... not sure why it didn't come up until after the release. I have opened a PR to revert #7503 edit: this was a network issue... please ignore me 😄 |
Yes. This works as expected, and IMHO |
getaddrinfo(3) may (should?) return EAI_AGAIN on DNS errors. Some
systems apparently returns 'ENOTFOUND' so we check both.
This makes the tests work with musl libc which correctly return
EAI_AGAIN.
For valid errors see:
http://pubs.opengroup.org/onlinepubs/009619199/getad.htm#tagcjh_05_06_05