-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DNS requests do not timeout #39562
Comments
@nodejs/dns |
Using the latest version of this repo, a timeout is given for me after ~50 seconds for a Initially it looks like the timeout being used is 10 * the
Can you confirm anything similar @nemanjan00? I'll do some digging in the meantime and update the thread if I find anything of interest. |
I get pretty much identical results Sounds like with some tuning I can get expected timeout, but, again, I do not want it to be fixed without me figuring out and having incorrect timeout :D Implemented additional timeout around it and hopefully it will be fixed :D |
This is due to c-ares (the lib underneath Node dns lib) by default, it retries timeout 4 times. That's why 300 * 1 + 3 retries = ~5s, for example. I went ahead and added 'tries' as an option for Resolver options. With that changes this: const dns = require('dns');
const resolver = new dns.Resolver({
timeout: 5 * 1000,
tries: 1,
});
resolver.setServers([
"123.123.123.123"
]);
resolver.resolve4("myip.opendns.com", (err, ip) => {
if (err) {
console.error(err);
} else console.log(ip);
}) Will correctly throw an exception after 5000ms. The pull request: #39610 |
It seems that this is resolved now that #39610 was merged. |
Version
v16.5.0
Platform
Linux terminator 5.13.5-zen1-1-zen #1 ZEN SMP PREEMPT Sun, 25 Jul 2021 18:03:00 +0000 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run this code:
How often does it reproduce? Is there a required condition?
It fails every single time
What is the expected behavior?
dns.TIMEOUT
is returned as error in callback.What do you see instead?
Request never times out.
Additional information
No response
The text was updated successfully, but these errors were encountered: