fetch times out in under 5 seconds
See original GitHub issueBug Description
When trying to fetch a URL a fetch failed
error is thrown with the code as
code: ‘UND_ERR_CONNECT_TIMEOUT’
, This error is thrown at a request that barely takes 5 - 6 seconds to complete and other HTTP clients like axios and curl perform flawlessly on the same server
Reproducible By
Fetch any discord API url
Expected Behavior
The fetch should complete which is well below the 120s timeout
Logs & Screenshots
/home/arnav/Documents/tej.js/node_modules/undici/lib/fetch/index.js:197
Object.assign(new TypeError('fetch failed'), { cause: response.error })
^
TypeError: fetch failed
at Object.processResponse (/home/arnav/Documents/tej.js/node_modules/undici/lib/fetch/index.js:197:23)
at /home/arnav/Documents/tej.js/node_modules/undici/lib/fetch/index.js:930:38
at node:internal/process/task_queues:141:7
at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
cause: ConnectTimeoutError: Connect Timeout Error
at Timeout.onConnectTimeout [as _onTimeout] (/home/arnav/Documents/tej.js/node_modules/undici/lib/core/connect.js:108:24)
at listOnTimeout (node:internal/timers:561:11)
at processTimers (node:internal/timers:502:7) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Environment
Gentoo, Node v17.6.0
Additional context
Happen on every discord API url and used to work some time back but suddenly just fails everywhere.
Issue Analytics
- State:
- Created a year ago
- Comments:21 (8 by maintainers)
Top Results From Across the Web
How to Timeout a fetch() Request - Dmitri Pavlutin
Users are OK to wait up to 8 seconds for simple requests to complete. That's why you need to set a timeout on...
Read more >Fetch API request timeout? - javascript - Stack Overflow
I want to know what is the default timeout for this? and how can we set it to a particular value like 3...
Read more >Quickie fetch timeout | Ben Ilegbodu
Libraries like axios provide lots of utilities for making HTTP requests, including timing out long-running requests. I've always used the native ...
Read more >How to Set Timeout with the JavaScript Fetch API using ...
Use the setTimeout function to trigger the abort method after a specified time(convert to seconds by multiplying by 1000) and returns the ...
Read more >A Complete Guide to Timeouts in Node.js - Better Stack
The above example sets the server timeout to 5 seconds so that inactive ... In Node.js, no default timeout is set for fetch()...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am also getting
UND_ERR_CONNECT_TIMEOUT
after ~5 secs when IPv6 is not configured or working properly. With curl, Chrome and other clients, it still works via IPv4. This seems to be because Node does not implement Happy Eyeballs. There is already an issue for this: https://github.com/nodejs/node/issues/41625That’s not the problem. The problem is that all those folks have IPv6 misconfigured and we are missing Happy Eyeballs in Node.js https://github.com/nodejs/node/issues/41625. Hopefully it will land before Node.js v18 goes LTS or shortly thereafter.