Skip to content

fix: treat empty dnsaddr answer as no addresses#3550

Merged
tabcat merged 2 commits into
libp2p:mainfrom
tabcat:fix/dnsaddr-empty-answer
Jul 3, 2026
Merged

fix: treat empty dnsaddr answer as no addresses#3550
tabcat merged 2 commits into
libp2p:mainfrom
tabcat:fix/dnsaddr-empty-answer

Conversation

@tabcat

@tabcat tabcat commented Jul 3, 2026

Copy link
Copy Markdown
Member

Description

@multiformats/dns 1.0.15 changed query() to throw an empty-answer error (so it can fall through to other resolvers) instead of returning an empty result. As a side effect, dialing a /dnsaddr/ that resolves to no records started rejecting with DNSQueryFailedError instead of NoValidAddressesError.

This catches the empty-answer case in the dnsaddr resolver so those dials fail with NoValidAddressesError again, while genuine DNS failures still surface as DNSQueryFailedError.

Notes & open questions

Root cause is multiformats/js-dns#34 (released in @multiformats/dns 1.0.15). No new test needed: the existing connections.spec.ts "should fail to dial if resolve fails and there are no addresses to dial" test exercises this path (it was failing on 1.0.15, passes with this change).

Change checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works

@multiformats/dns 1.0.15 throws on an empty answer instead of returning an empty result. Catch that in the dnsaddr resolver so a dnsaddr with no records fails with NoValidAddressesError, while real DNS failures still surface as DNSQueryFailedError.
@tabcat

tabcat commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

It's probably more helpful to throw the DNS error but this gets everything working with the same behavior as before. We can decide on what error to throw later.

@tabcat tabcat marked this pull request as ready for review July 3, 2026 05:53
@tabcat tabcat requested a review from a team as a code owner July 3, 2026 05:53
@tabcat tabcat merged commit 3c8a559 into libp2p:main Jul 3, 2026
74 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant