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.reverse incorrectly throws exception when no address found #45575

Closed
Worthaboutapig opened this issue Nov 22, 2022 · 3 comments
Closed

dns.reverse incorrectly throws exception when no address found #45575

Worthaboutapig opened this issue Nov 22, 2022 · 3 comments
Labels
dns Issues and PRs related to the dns subsystem.

Comments

@Worthaboutapig
Copy link

Worthaboutapig commented Nov 22, 2022

Version

v18.12.1

Platform

Linux live 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

node:dns

What steps will reproduce the bug?

var dns = require("node:dns");
var resolver = new dns.Resolver();

resolver.reverse("142.250.180.4", function (err, addresses) {
  if (err) {
    console.error(err);
  } else {
    console.info("addresses:", addresses);
  }
});

resolver.reverse("5.150.98.53", function (err, addresses) {
  if (err) {
    console.error(err);
  } else {
    console.info("addresses:", addresses);
  }
});

How often does it reproduce? Is there a required condition?

This happens always as it is a design issue.

What is the expected behavior?

Rather than throwing an Error, the resultant list of addresses should indicate that the address lookup did not produce a reverse DNS record, say by returning false, instead of the string address.

addresses: [ false ]

What do you see instead?

The second result (where the reverse record does not exist) produces:

Error: getHostByAddr ENOTFOUND 5.150.98.53
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:47:19) {
  errno: undefined,
  code: 'ENOTFOUND',
  syscall: 'getHostByAddr',
  hostname: '5.150.98.53'

Additional information

There is no requirement that an IP address resolve to a DNS name, so this shouldn't throw an error, as it's not an exception state, it's that a record could not be found and that's a valid result from the DNS query. They're not the same thing.

Essentially, this makes debugging actual issues really hard, because catching all errors picks this up constantly where it shouldn't. The resolution is not expected to produce a record, and that's fine, so there should be a "not found" result of some sort.

@Trott
Copy link
Member

Trott commented Nov 22, 2022

@nodejs/dns

@bnoordhuis
Copy link
Member

this shouldn't throw an error, as it's not an exception state

Even if if this ends up being the consensus (and reasonable people can disagree), the existing behavior has been around too long to change.

@VoltrexKeyva VoltrexKeyva added the dns Issues and PRs related to the dns subsystem. label Nov 22, 2022
@bnoordhuis
Copy link
Member

Since no one else chimed in, I'll go ahead and close this as a wontfix.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dns Issues and PRs related to the dns subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants