-
Versionv18.14.2 PlatformDarwin N61M66G4LW.lan 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64 Subsystemdns What steps will reproduce the bug?Running multiple parallel dns.lookup() on my Apple Silicon Macbook sometimes gets the classic I first ran into this issue trying to use certain packages in parallel (eg: Sample script: const dns = require('node:dns');
const util = require('util');
const promiseLookup = util.promisify(dns.lookup);
const host = 'github.com';
// const host = 'google.com'; // Certain hosts seems to succeed
async function test() {
try {
const requests = [];
for (let i = 0; i < 1000; i++) {
const options = {};
// options.family = 4; // Specifying family: 4 seems to succeed
// await promiseLookup(host, options); // Awaiting the lookups in sequence seems to succeed
requests.push(promiseLookup(host, options));
}
await Promise.all(requests);
console.log('success');
} catch (err) {
console.log(err);
}
}
test(); I commented out 3 lines which each individually seem to fix the issue for me, but I'm not sure how to fix it for the package dependencies that I'm using. How often does it reproduce? Is there a required condition?I can reproduce it around 50% of the time with the sample script. But it seems to reliably get fixed for me if any of these are true:
Here are all the other things I've tried so far, that haven't seemed to fix it:
What is the expected behavior? Why is that the expected behavior?The DNS lookups should consistently succeed when ran in parallel What do you see instead?
> node sample-script.js
Error: getaddrinfo ENOTFOUND github.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'github.com'
} Additional informationI haven't been able to reproduce it with parallel DNS lookups in a similar golang sample program on the same machine. I also haven't been able to reproduce it using I've been using an Apple Silicon Macbook since 2021, but only started seeing this error during summer 2023. But I wasn't previously testing parallel DNS lookups, so I'm not sure if it's been an issue for me for 2 years or not. My coworkers on other Apple Silicon Macbooks can also reproduce the issue. Interestingly, some of them on Intel processor Macbooks cannot seem to reproduce it. I understand that there are potentially many similar issues and workarounds from nodejs/node#5436, and that it might be an OS-specific issue related to libc versions. I'm confused why I'm not seeing any other recent issues for this other than from 2019 - maybe I'm missing something. I'm wondering if there's any workarounds from node that I can use in the meantime. Since setting |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 6 replies
-
@nodejs/dns |
Beta Was this translation helpful? Give feedback.
-
Inactionable as a bug report, the linked issue explains why it's not under node's control. Use dns.resolve() if dns.lookup() is giving you trouble. Setting I'll convert this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
My goal is to find a suitable workaround for the specific package dependencies that I'm using. In this case, various Since it's a nested dependency package that is doing the DNS lookup, I cannot easily change it to use My best workaround so far is to try and patch the eg: something like this near process start:
I plan to also reach out to AWS and Apple support, to see if they have any better workarounds. I'll add another comment if I find anything better |
Beta Was this translation helpful? Give feedback.
-
I have similar problems in some of the codebases I work in. Setting |
Beta Was this translation helpful? Give feedback.
-
I have a similar issue with I think that the reason this issue is not more wide spread is that, from what people report, it only happens under certain conditions:
Based on reports that increasing I'd also be careful with setting For new code, I'm wrapping my When patching |
Beta Was this translation helpful? Give feedback.
My goal is to find a suitable workaround for the specific package dependencies that I'm using. In this case, various
@aws-sdk
packages (eg:@aws-sdk/client-ssm
).Since it's a nested dependency package that is doing the DNS lookup, I cannot easily change it to use
dns.resolve()
, nor directly configure it to use{family:4}
My best workaround so far is to try and patch the
dns.lookup
method to always set family:4, but I'm not sure if this can cause other issues.eg: something like this near process start: