DNS resolution fails for internationalized domain names

  • Version: v10.14.2
  • Platform: Darwin november.local 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
  • Subsystem: dns, cares_wrap

Currently the DNS module seems to utf-8 encode the names passed to c-ares for DNS resolution:

node::Utf8Value name(env->isolate(), string);

That doesn't work for internationalized domain names, which need to be IDNA encoded.

DNS is pretty much all ASCII, so IMHO Node shouldn't utf-8 encode on input.

Here is a list of international domain names to test.

This will produce an error:

> dns.resolve('españa.icom.museum', function(r, e) { console.log(r, e) })`
> { Error: queryA ENOTFOUND españa.icom.museum
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:197:19)
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'queryA',
  hostname: 'españa.icom.museum' } undefined

Whereas the proper IDNA encoded version works:

> dns.resolve('xn--espaa-rta.icom.museum', function(e, r) { console.log(e, r) })
> null [ '91.194.60.138' ]