haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
4.91k stars 653 forks source link

dns.resolveMx might fail in specific cases in Node <22 #3381

Open analogic opened 3 days ago

analogic commented 3 days ago

Not a Haraka bug, but a pretty important node issue that affects the deliverability for Haraka outbound. So I thought it would be a good idea to report it here as well...

See this example:

$ docker run -ti node:22 node
...
> const dns = require('dns');
> const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]
$ docker run -ti node:20 node
...
> const dns = require('dns');
> const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]
$ dig mx +short blek.cz 
100 blekmx1.blek.cz.

Bare "blek.cz" does not have smtp open, so it bounces. I have found no irregularities in this particular DNS record - even sniffed comm looks correct.

baudehlo commented 3 days ago

Could this be a docker issue?

╰─ node

  ─╯

Welcome to Node.js v20.11.0.

Type ".help" for more information.

const dns = require('dns');

undefined

const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

undefined

[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

On Tue, Jul 2, 2024 at 10:48 AM analogic @.***> wrote:

Not a Haraka bug, but a pretty important node issue that affects the deliverability for Haraka outbound. So I thought it would be a good idea to report it here as well...

See this example:

$ docker run -ti node:22 node ...

const dns = require('dns'); const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

$ docker run -ti node:20 node ...

const dns = require('dns'); const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ dig mx +short blek.cz 100 blekmx1.blek.cz.

Bare "blek.cz" does not have smtp open, so it bounces. I have found no irregularities in this particular DNS record - even sniffed comm looks correct.

— Reply to this email directly, view it on GitHub https://github.com/haraka/Haraka/issues/3381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFBWY47QRKOTUFTPXUNPKDZKK4VFAVCNFSM6AAAAABKHXE4XWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4DMNBXGA2TAMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

analogic commented 3 days ago

Maybe, but see: (shortened)

$ docker run -ti node:16 node
[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

$ docker run -ti node:18 node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:20 node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:20-alpine node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:22 node
[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

It could be host system related (resolver?) and also there should be something unusual about this particular domain. I have confirmed this on Ubuntu & Red Hat

analogic commented 1 day ago

ref https://github.com/nodejs/node/issues/53708