-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
dns: return real system error instead of 'ENOTFOUND' #5196
Conversation
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.
Like @silverwind said, this would definitely be a breaking change. I do not mind if this gets landed in the interim, before #1843 (if it does land), as that PR could still be awhile yet. |
@mscdex are you in support of these system error codes? I'd say if we're going to mess with these, we should just do DNS error codes, if the c-ares codes can all be mapped to DNS errors (which I doubt). |
@silverwind I'm not sure that the actual DNS status codes are available? I haven't really looked into it though. There will probably still need to be non-DNS error names though for problems that arise that don't fit any of the DNS status codes. |
@@ -3,12 +3,12 @@ var common = require('../common'); | |||
var net = require('net'); | |||
var assert = require('assert'); | |||
|
|||
var c = net.createConnection(common.PORT, '...'); | |||
var c = net.createConnection(common.PORT, '***'); |
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.
What's the reason for changing ...
to ***
? (Sorry if it's a naive question.)
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.
@Trott as I tried to explain in the commit message, the getaddrinfo()
error code when hostname is ...
is different on different systems:
libc | hostname | getaddrinfo() error code |
---|---|---|
glibc | ... |
EAI_NONAME |
musl | ... |
EAI_AGAIN |
glibc | *** |
EAI_NONAME |
musl | *** |
EAI_NONAME |
So I changed the hostname instead of testing for both error codes:
c.on('error', common.mustCall(function(e) {
- assert.equal(e.code, 'ENOTFOUND');
+ assert(e.code == 'EAI_NONAME' || e.code == 'EAI_AGAIN');
assert.equal(e.port, common.PORT);
Also, on musl using ...
would make the test to wait for a timeoutm while using ***
would fail instantly.
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.
I am open for suggestions for a better commit message.
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.
@ncopa Totally my fault for not reading the commit message before commenting!
@nodejs/ctc ... any thoughts on this one? |
Maybe @ChALkeR, someone at npm, or someone else who is clever can give us an idea of how often |
IMO this probably has too big an impact to even do on a semver-major, the ship might have sailed on this. Perhaps a compromise would be to use the original code as an additional property on the
@bnoordhuis what are your thoughts here since it's your TODO being addressed? |
One possibility: we could document a pending deprecation of |
I'm |
@bnoordhuis @nodejs/ctc ... thoughts on this? Specifically my proposal here: #5196 (comment) |
7da4fd4
to
c7066fb
Compare
@jasnell I'm not sure we can "deprecate" |
Is there a way we could append an additional property specifically for these errors? That is the only option that comes to mind other than a hard switch... |
@trevnorris ... yes, by "deprecation" I mean only giving users a clear indication that a hard swap would be made after v7 ... not a deprecation in the traditional sense with a printed warning. |
@Trott https://gist.github.com/ChALkeR/b720b21c377809e0eb2796aa5df42bfa — the usage is quite low. Update: sorted the list by downloads/month. |
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 |
Hmm I think I'm -1 on this at this point. Different errors for different libc implementations seems like a unneccesary detail we shouldn't expose our users to. I see some value in having real DNS errors like |
I think this actually is a bug in musl libc. I sent a patch for fixing it. I will follow that up. |
c133999
to
83c7a88
Compare
@nodejs/ctc ... and @bnoordhuis in particular... is this something we'd actually want to do at this point? |
We could just attach the real error to the existing error, right? |
yep.. we don't have an existing property we can use but we can certainly make one. |
I could live with a |
ping @ncopa |
Closing due to lack of further activity. |
Return the real system error to user insetad of injecting 'ENOTFOUND'
which is not a proper POSIX error.
#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.