I am trying to debug the node-sendmail package, more specifically I would like to understand the error I am getting when using the gmail.com host domain. The error only happens on my Ubuntu 20.04 running under WSL2.
What confuses me is that resolveMx works fine on Windows (with gmail) and it is also working on both (wsl Ubuntu and Windows) with other domain, like protonmail.
Running nslookup or dig also works for the gmail domain on wsl, so it really looks like it's the the syscall used underneath by nodejs which is behaving inconsistently.
In both OSes I am using the same nodejs version: 14.15.4.
The snippet I am using:
const dns = require('dns');
const util = require('util');
dns.resolveMx('gmail.com', (err, addresses) => {
if (err){
console.log(err); // going here, see error message below
return;
}
console.log(util.inspect(addresses));
});
giving the following error, only for the Ubuntu hosted on WSL2:
Error: queryMx ETIMEOUT gmail.com
at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) {
errno: undefined,
code: 'ETIMEOUT',
syscall: 'queryMx',
hostname: 'gmail.com'
}
On Windows, I got the expected result:
[
{ exchange: 'alt1.gmail-smtp-in.l.google.com', priority: 10 },
{ exchange: 'gmail-smtp-in.l.google.com', priority: 5 },
{ exchange: 'alt4.gmail-smtp-in.l.google.com', priority: 40 },
{ exchange: 'alt3.gmail-smtp-in.l.google.com', priority: 30 },
{ exchange: 'alt2.gmail-smtp-in.l.google.com', priority: 20 }
]
What confused me even more, is that, if I change gmail for another provider, like protonmail for instance, the mx resolution is working on both wsl distro and Windows.
Update
The problem occurs inconsistently, since I got resolveMx working sometime on wsl as well.