-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
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:
-
It's an artificial error that was introduced for $reasons in Node.js v0.2.0.1
-
It's been around long enough that simply removing it won't fly.
-
It's returned when getaddrinfo() fails with EAI_NODATA or EAI_NONAME.
-
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().