diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index fa8f0b8cf14103..0d1f817593f2e7 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -2,7 +2,6 @@ const { ArrayPrototypeForEach, - ArrayPrototypeJoin, ArrayPrototypeMap, ArrayPrototypePush, FunctionPrototypeBind, @@ -143,12 +142,15 @@ class ResolverBase { } [kSetServersInteral](newSet, servers) { - const orig = this._handle.getServers() || []; + const orig = ArrayPrototypeMap(this._handle.getServers() || [], (val) => { + val.unshift(isIP(val[0])); + return val; + }); const errorNumber = this._handle.setServers(newSet); if (errorNumber !== 0) { // Reset the servers to the old servers, because ares probably unset them. - this._handle.setServers(ArrayPrototypeJoin(orig, ',')); + this._handle.setServers(orig); const { strerror } = lazyBinding(); const err = strerror(errorNumber); throw new ERR_DNS_SET_SERVERS_FAILED(err, servers);