finalchild commented on code in PR #479:
URL: 
https://github.com/apache/cassandra-nodejs-driver/pull/479#discussion_r4221917589


##########
lib/control-connection.js:
##########
@@ -895,40 +895,21 @@ class ControlConnection extends events.EventEmitter {
   }
 
   /**
-   * Uses the DNS protocol to resolve a IPv4 and IPv6 addresses (A and AAAA 
records) for the hostname.
+   * Uses the operating system resolver to resolve all IPv4 and IPv6 addresses 
for the hostname.
    * It returns an Array of addresses that can be empty and logs the error.
    * @private
    * @param name
    */
   async _resolveAll(name) {
-    const addresses = [];
-    const resolve4 = util.promisify(dns.resolve4);
-    const resolve6 = util.promisify(dns.resolve6);
     const lookup = util.promisify(dns.lookup);
 
-    // Ignore errors for resolve calls
-    const ipv4Promise = resolve4(name).catch(() => {}).then(r => r || 
utils.emptyArray);
-    const ipv6Promise = resolve6(name).catch(() => {}).then(r => r || 
utils.emptyArray);
-
-    let arr;
-    arr = await ipv4Promise;
-    arr.forEach(address => addresses.push({address, isIPv6: false}));
-
-    arr = await ipv6Promise;
-    arr.forEach(address => addresses.push({address, isIPv6: true}));
-
-    if (addresses.length === 0) {
-      // In case dns.resolve*() methods don't yield a valid address for the 
host name
-      // Use system call getaddrinfo() that might resolve according to host 
system definitions
-      try {
-        arr = await lookup(name, { all: true });
-        arr.forEach(({address, family}) => addresses.push({address, isIPv6: 
family === 6}));
-      } catch (err) {
-        this.log('error', `Host with name ${name} could not be resolved`, err);
-      }
+    try {
+      const addresses = await lookup(name, { all: true });

Review Comment:
   I think this PR's scope does not include deciding that we should ignore 
`setDefaultResultOrder`.
   
   https://nodejs.org/api/dns.html#dnslookuphostname-options-callback
   
   Starting from Node 17, verbatim defaults to true and Copilot is right about 
`setDefaultResultOrder` being able to override the default.
   
   === node docs ===
   
   verbatim <boolean>
   
   When true, the callback receives IPv4 and IPv6 addresses in the order the 
DNS resolver returned them. When false, IPv4 addresses are placed before IPv6 
addresses. This option will be deprecated in favor of order. When both are 
specified, order has higher precedence. New code should only use order. 
Default: true (addresses are not reordered). Default value is configurable 
using 
[dns.setDefaultResultOrder()](https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder)
 or 
[--dns-result-order](https://nodejs.org/api/cli.html#--dns-result-orderorder).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to