Skip to content

dnsPromises Resolver with IDN certain subdomains #39139

@7c

Description

@7c

Certain version does throw error:

TypeError: Cannot convert name to ASCII
    at Resolver.queryA [as resolve4] (dns.js:227:48)

with MacOS BigSur Darwin Kernel Version 20.5.0, node v14.15.4 but does work with node v10.15.3 (ubuntu) and v10.24.1 (ubuntu).

Code which does this unexpected behaviour:

var { Resolver } = require('dns');
var resolver = new Resolver()
resolver.setServers(['8.8.8.8'])

function nslookup(host) {
    return new Promise(async function (resolve,reject) {
        console.log(`nslookup(${host})`)
        resolver.resolve4(host,function(err,ips) {
            if (err) {
                console.log(err)
                return resolve(false)
            }
            console.log(ips)
            return resolve(true)
        })
    })
    
}

async function start() {
    await nslookup('a.xn--ngbq.com')        // success
    await nslookup('ab.xn--ngbq.com')       // success
    await nslookup('a0.xn--ngbq.com')       // success
    await nslookup('1.xn--ngbq.com')        // fails
    await nslookup('10000.xn--ngbq.com')    // fails

    
}

start()

for some reason, a valid IDN domain like xn--nqbg.com does with alphanumeric hosts but does not work with number subdomains at my bigsur mac with node v14.15.4, upgraded to v14.17.1 and it still fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    dnsIssues and PRs related to the dns subsystem.i18n-apiIssues and PRs related to the i18n implementation.icuIssues and PRs related to the ICU dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions