You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: if you supply custom DNS lookup in 1.6+ and it fails with ENOTFOUND, axios throws TypeError: address must be a string instead
I supply custom DNS lookup to precisely control the timeout. I am using https://github.com/szmarczak/cacheable-lookup. It works correctly in axios before 1.6 but fails after because of this change:
When the callback returns the err as the first argument, the other two can be (and are) undefined. Axios 1.6+ attempts to resolve family and address regardless of err and trips over undefined.
Take a look:
To Reproduce
Perform axios request against a domain that does not exists with a custom lookup. DNS lookup fails with ENOTFOUND but axios then fails with TypeError: address must be a string
axios should fail with the DNS lookup error, not the TypeError
Axios Version
1.6+
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered:
pveller
changed the title
dns lookup introduced in 1.6 incorrectly attempts to resolve address in case of an error from the lookup callback
dns lookup upgraded in 1.6 incorrectly attempts to resolve address in case of an error from the lookup callback
Jan 4, 2024
Describe the bug
TL;DR: if you supply custom DNS
lookup
in 1.6+ and it fails withENOTFOUND
,axios
throwsTypeError: address must be a string
insteadI supply custom DNS
lookup
to precisely control the timeout. I am using https://github.com/szmarczak/cacheable-lookup. It works correctly in axios before 1.6 but fails after because of this change:When the callback returns the
err
as the first argument, the other two can be (and are)undefined
. Axios 1.6+ attempts to resolvefamily
andaddress
regardless oferr
and trips overundefined
.Take a look:
To Reproduce
Perform axios request against a domain that does not exists with a custom
lookup
. DNSlookup
fails withENOTFOUND
butaxios
then fails withTypeError: address must be a string
Code snippet
Expected behavior
axios
should fail with the DNSlookup
error, not theTypeError
Axios Version
1.6+
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: