Skip to content

dns: provide additional info for ENOTFOUND errors #26903

@bnoordhuis

Description

@bnoordhuis

Refs: #5436 - and plenty of other issues.

That issue attracts comments from befuddled users to this day so I think it highlights a real issue, namely that the ENOTFOUND error code on its own is not very helpful.

History/background/context:

  1. It's an artificial error that was introduced for $reasons in Node.js v0.2.0.1

  2. It's been around long enough that simply removing it won't fly.

  3. It's returned when getaddrinfo() fails with EAI_NODATA or EAI_NONAME.

  4. It nearly always indicates some transient or environmental error condition: out of file descriptors, no network connectivity, upstream DNS server timing out, etc.

It would be nice to provide a better error message, perhaps through an additional status property if necessary for backwards compatibility.

The problem: there might not be sufficient metadata to provide a better message.

For example, glibc returns EAI_NONAME when there is no IPv6 connectivity and the host only has an IPv6 address. There is no way to dinstinguish that particular condition from a real NXDOMAIN error apart from opting out from glibc's default behavior (see libuv/libuv#2225 - probably has wider-ranging consequences.)

1 For the curious: it maps directly to ARES_ENOTFOUND, the c-ares error code. That's from before Node.js supported getaddrinfo().

Metadata

Metadata

Assignees

No one assigned

    Labels

    dnsIssues and PRs related to the dns subsystem.feature requestIssues that request new features to be added to Node.js.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions