Skip to content

dns docs are missing that family = 0 for dns.lookup is allowed #28159

Description

@daprahamian
  • Node.js Version: 12.2
  • OS: macOs
  • Scope (install, code, runtime, meta, other?): runtime
  • Module (and version) (if relevant): dns, net, tls

Quick question: is dns.lookup(url, 0, callback) supported as part of Node's API? The documentation says Must be 4 or 6, and any positive integer other than 4 or 6 will return a TypeError [ERR_INVALID_OPT_VALUE]: The value "2" is invalid for option "family". But passing in 0 does not error. Is this expected? If so, is this something stable that developers can rely on?

// The following are all expected to work
dns.lookup('www.google.com', 4, err => {
  console.log(err); // null
});
dns.lookup('www.google.com', 6, err => {
  console.log(err); // null
});
dns.lookup('www.google.com', err => {
  console.log(err); // null
});

// The following should error
try {
  dns.lookup('www.google.com', 1, () => {});
} catch (e) {
  console.log(e); // TypeError [ERR_INVALID_OPT_VALUE]: The value "1" is invalid for option "family"
}
try {
  dns.lookup('www.google.com', 2, () => {});
} catch (e) {
  console.log(e); // TypeError [ERR_INVALID_OPT_VALUE]: The value "2" is invalid for option "family"
}
try {
  dns.lookup('www.google.com', 3, () => {});
} catch (e) {
  console.log(e); // TypeError [ERR_INVALID_OPT_VALUE]: The value "3" is invalid for option "family"
}
try {
  dns.lookup('www.google.com', 5, () => {});
} catch (e) {
  console.log(e); // TypeError [ERR_INVALID_OPT_VALUE]: The value "5" is invalid for option "family"
}

// Asking about this one:
dns.lookup('www.google.com', 0, err => {
  console.log(err); // null <-- is this correct?
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dnsIssues and PRs related to the dns subsystem.docIssues and PRs related to Node.js documentation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions