Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error message could be improved for dns.lookupService #29039

Copy link
Copy link
@ORESoftware

Description

@ORESoftware
Issue body actions

I am on Node.js v12.6

I have this issue:
nodejs/help#2106

I think the error message is mis-named. The error message should be:

There was an error: TypeError [ERR_INVALID_OPT_VALUE]: The value "google.com" is invalid for option "address"

but the error message is:

There was an error: TypeError [ERR_INVALID_OPT_VALUE]: The value "google.com" is invalid for option "hostname"

this will work:

const dns = require('dns');

const getDNSInfo = (host) => new Promise(resolve => {
  dns.lookup(host, (err, hostname, service) => {
    console.log('dns resolved:', {hostname, service, err});
    resolve({err, hostname, service});
  });
});

getDNSInfo('google.com').then(v => {
   console.log(v);
})
.catch(v => {
  console.error('There was an error:', v)
});

but this doesn't:

const dns = require('dns');

const getDNSInfo = (host, port) => new Promise(resolve => {
  dns.lookupService(host, port, (err, hostname, service) => {
    console.log('dns resolved:', {hostname, service, err});
    resolve({err, hostname, service});
  });
});

getDNSInfo('google.com', 80).then(v => {
   console.log(v);
})
.catch(v => {
  console.error('There was an error:', v)
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.