What exactly changed between Node.js 18 and Node.js 20 that's causing my API requests to fail? #4797
Unanswered
hrishikesh-k
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
My setup:
The reasons for mentioning all that will be evident in the rest of the message. I had the following piece of code (simplified for demonstration):
This was working fine until I was using Node.js 18 (last tested on 18.18.2 and 19.9.0). Since Node.js 20 went to LTS, I decided to upgrade and the code started to fail with this error:
It took me a long time to figure out what's going on here. I even reached out to Discourse: https://meta.discourse.org/t/285921 and the TL;DR was:
This finally works on Node.js 20 by changing the above code to:
I had to specify the family to force the connections through IPv4.
I have tried specifying
--dns-result-order=ipv4first
without success. I also checked the release notes: https://nodejs.org/en/blog/announcements/v20-release-announce which don't mention any related changes.I simply wish to know what exactly has changed in Node.js causing this issue and how to adapt the application to work with it? I was trying to move away from Axios to Wretch which is a
fetch
based library andfetch
doesn't provide any way to customise whether I can use IPv4 or IPv6.Beta Was this translation helpful? Give feedback.
All reactions