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

dns.lookup() documentation error code #27604

Closed
nfearnley opened this issue May 7, 2019 · 3 comments
Closed

dns.lookup() documentation error code #27604

nfearnley opened this issue May 7, 2019 · 3 comments

Comments

@nfearnley
Copy link
Contributor

  • Version: v11.15.0
  • Platform: N/A
  • Subsystem: N/A

The nodejs documentation for dns.lookup() seems to imply that the error will ENOENT, if a domain is not found. Should this be ENOTFOUND instead?

https://nodejs.org/docs/latest-v11.x/api/dns.html#dns_dns_lookup_hostname_options_callback

"On error, err is an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOENT' not only when the hostname does not exist but also when the lookup fails in other ways such as no available file descriptors."

@Trott
Copy link
Member

Trott commented May 8, 2019

I'm certainly getting ENOTFOUND locally when dns.lookup() fails to find an address. And it's also what I get for valid names if I set ulimit -n sufficiently low. So it sure seems to be the case that ENOTFOUND might sometimes mean "no available file descriptors" (or at least something that isn't actually "address not found") in this case, which is really unfortunate IMO. EDIT: I'm on macOS, just in case this is platform-dependent behavior.

@sagitsofan
Copy link
Contributor

It seems that dns.lookup() will always return ENOTFOUND on a empty lookup or when the host not found.
https://github.com/nodejs/node/blob/master/lib/internal/errors.js#L503
Should we change the error code or fixed the documentation?

@Trott
Copy link
Member

Trott commented May 13, 2019

Fixed in fd8d5e7

@Trott Trott closed this as completed May 13, 2019
Trott pushed a commit to Trott/io.js that referenced this issue May 13, 2019
dns.lookup() will always return ENOTFOUND on a empty lookup
or when the host not found.
https://github.com/nodejs/node/blob/master/lib/internal/errors.js#L503

Fixes: nodejs#27604

PR-URL: nodejs#27625
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue May 14, 2019
dns.lookup() will always return ENOTFOUND on a empty lookup
or when the host not found.
https://github.com/nodejs/node/blob/master/lib/internal/errors.js#L503

Fixes: #27604

PR-URL: #27625
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants