profile
viewpoint

Ask questionsLocal DNS resolution sometimes fails

<!-- Thank you for reporting a possible bug in Node.js.

Please fill in as much of the template below as you can.

Version: output of node -v Platform: output of uname -a (UNIX), or version and 32 or 64-bit (Windows) Subsystem: if known, please specify the affected core module name

If possible, please provide code that demonstrates the problem, keeping it as simple and free of external dependencies as you can. -->

  • Version: v12.4.0 + v10.16.0 + v10.13.0
  • Platform: Darwin hosea 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Subsystem: dns

<!-- Please provide more details below this comment. -->

When running multiple DNS queries in parallel using promises, the DNS resolution sometimes fails. We only noticed that on macOS so far.

Sample script:

const dns = require("dns");
const util = require("util");

const requests = [];
for (let i = 0; i < 1000; i++) {
  requests.push(
    util.promisify(
      dns.lookup
    )('waldbuehne-heessen.de')
  );
}
Promise
  .all(requests)
  .then(() => {
    console.log("ok");
  })
  .catch(error => {
    console.log(error);
    return error;
  });

Output (sometimes):

Error: getaddrinfo ENOTFOUND waldbuehne-heessen.de
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'waldbuehne-heessen.de'
}

During the execution, no DNS queries are sent out (tested using tcpdump), so only the local DNS cache seems to be involved.

nodejs/node

Answer questions dploeger

@sam-github Yes, same result with the direct promises API.

useful!
source:https://uonfu.com/
Github User Rank List