Skip to content

dns.resolveMx returns invalid result in Node <22 #53708

Closed

Description

@analogic

Version

v20.15.0

Platform

linux & docker

Subsystem

dns

What steps will reproduce the bug?

I have this code:

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

And results:

$ 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 } ] ]

How often does it reproduce? Is there a required condition?

Might be system/resolver dependent. Also there should be something unusual about this particular domain

What is the expected behavior? Why is that the expected behavior?

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

What do you see instead?

Bare "blek.cz" host even don't have SMTP port open so it makes emails undeliverable

Additional information

No response

Activity

  1. JQuags commented on Jul 4, 2024

    @JQuags

    I am able to reproduce this on freebsd (13.3) with blek.cz and visa.com but not gmail.com and other domains however unlike the above test it also is an issue in v22.3.0 installed from ports.

  2. targos commented on Jul 5, 2024

    @targos
    Member

    I verified that it was fixed by #53155 in Node.js 22.3.0.

    Probably due to this (from c-ares changelog):

    Due to a logic flaw dns name compression writing was not properly implemented
    which would result in the name prefix not being written for a partial match.
    This could cause issues in various record types such as MX records when using
    the deprecated API. Regression introduced in 1.28.0. Issue #757

  3. avivkeller commented on Jul 6, 2024

    @avivkeller
    Member

    Does that make this is a known limitation?

  4. targos commented on Jul 6, 2024

    @targos
    Member

    No

  5. avivkeller commented on Jul 6, 2024

    @avivkeller
    Member

    So, IIUC the solution would be to backport c-ares/c-ares@d7c14a1?

  6. targos commented on Jul 6, 2024

    @targos
    Member

    No, the solution is to cherry-pick or backport #53155. That's why I added lts-watch- labels to it.

  7. avivkeller commented on Jul 6, 2024

    @avivkeller
    Member

    Oh, thanks, I don't know that much about backporting, thanks for the info!

  8. added
    caresIssues and PRs related to the c-ares dependency or the cares_wrap binding.
    on Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    caresIssues and PRs related to the c-ares dependency or the cares_wrap binding.confirmed-bugIssues and PRs for confirmed bugs.dnsIssues and PRs related to the dns subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions