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

Handle ENOENT Windows lookup failures #50

Merged
merged 1 commit into from
Oct 18, 2021

Conversation

pimterry
Copy link
Contributor

Fixes #49

This can happen when, for example, you query with {family:6} on Windows but only IPv4 resolution is available.

It's very difficult to pin down all the possible error cases for DNS, but I think this happens because:

  • uv__getaddrinfo_translate_error in libuv for Windows falls back to uv_translate_sys_error (here)
  • uv_translate_sys_error maps WSANO_DATA to ENOENT (here)
  • WSANO_DATA is returned by Windows when the name exists, but not the requested record type. See https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2, which says:

    The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. The usual example for this is a host name-to-address translation attempt (using gethostbyname or WSAAsyncGetHostByName) which uses the DNS (Domain Name Server). An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable.

This shouldn't ever be returned on Unix OSs, which have their own separate & fixed list of possible errors (here).

There's more discussion and an (unmerged) PR to fix this properly and line up Unix & Windows DNS error handling here: libuv/libuv#2959

This can happen when, for example, you query with {family:6} but only
IPv4 resolution is available.
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2021

Codecov Report

Merging #50 (c39038f) into master (4a22f87) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #50   +/-   ##
=======================================
  Coverage   98.98%   98.98%           
=======================================
  Files           1        1           
  Lines         197      197           
=======================================
  Hits          195      195           
  Misses          2        2           
Impacted Files Coverage Δ
source/index.js 98.98% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a22f87...c39038f. Read the comment docs.

@szmarczak szmarczak merged commit 598e234 into szmarczak:master Oct 18, 2021
@pimterry pimterry deleted the handle-enoent branch October 18, 2021 09:05
@szmarczak
Copy link
Owner

Thanks! 🙌🏼 Released 6.0.4

@pimterry
Copy link
Contributor Author

Awesome, thanks! 👍

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 this pull request may close these issues.

Fallback fails when one family returns ENOENT
3 participants