Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

ipfs.dns does not handle subdomains correctly #1932

@niinpatel

Description

@niinpatel

When I do ipfs.dns('docs.ipfs.io'). It throws an error 'ENODATA'. I did some digging and found out that this error is thrown by nodejs' dns.resolveTxt method when it does not find any txt records.

Now, to handle subdomain correctly, we need to append _dnslink. string to it, which we do here

const _dnslinkDomain = `_dnslink.${domain}`
// If this throws then we propagate the error
return resolveDnslink(_dnslinkDomain)

But, the problem is, the error is way before the line gets to be executed, here:

if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND') throw err

The easiest solution to this problem would be to check for err.code 'ENODATA' also along with 'ENOTFOUND', etc. in the if condition. So, the next lines get a chance to be executed.

Basically something like this:

      if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND' && err.code !== 'ENODATA') throw err

Would fix the problem.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions