From 1b47fd2096fabe634b9377454436a6bbdf63ab5d Mon Sep 17 00:00:00 2001 From: mmorrison Date: Tue, 15 Oct 2019 14:32:28 -0500 Subject: [PATCH] Support dnsLookupAsync returning a string for some reason, Fixes #135 --- lib/DnsResolver.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/DnsResolver.js b/lib/DnsResolver.js index 7cfdd22..33aa041 100644 --- a/lib/DnsResolver.js +++ b/lib/DnsResolver.js @@ -62,7 +62,15 @@ class DnsResolver { } this.logger.debug("Standard Resolve: " + host); - const {address,family} = await dnsLookupAsync(host); + const dnsResult = await dnsLookupAsync(host); + // For some reason, this sometimes returns a string address rather than an object. + // I haven't been able to reproduce, but it's been reported on the issue tracker. + let address; + if (typeof dnsResult === 'string') { + address = dnsResult; + } else { + address = dnsResult.address; + } this.logger.debug("Found address: " + address); return {address: address}; }