-
Notifications
You must be signed in to change notification settings - Fork 7.3k
dns.lookup fails when offline on Windows #25338
Comments
which node version are you running? |
Running v0.12.2 x64. |
First off you should really be using the constants, ie:
Secondly the behaviour you describe is expected. From the documentation:
|
Thanks for piecing that together and correcting the example code @dnakamura. Since the API confirms this expected behaviour, I guess we should close this issue and open one against Socket.prototype.connect for improperly handling the ENOENT error thrown when performing the dns.lookup on localhost. Sound good? |
yeah |
@seanpoulter @dnakamura ... did the other issue get opened? Closing this but want to make sure the other issue is not dropped. |
I fixed this by modifying below line in file: \node_modules\mysql\lib\ConnectionConfig.js |
From dns.js,
dns.lookup
for"localhost"
fails, throwing an ENOENT error from getaddrinfo. It's reproducible with the following block:Running it when connected produces the output:
but without a network connection:
Unfortunately debugging even this simple block with
node debug <file>
fails trying to connect to port 5858:One solution is to patch dns.js to replace
"localhost"
with"127.0.0.1"
which produces the expected output, but I think the better solution is to fix thegetaddrinfo
calls.The text was updated successfully, but these errors were encountered: