Comments (15)
Thanks for reporting!
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
from undici.
repo is here: https://github.com/guotie/fetch-failed
I think the problem is timeout.
when the network is Ok, it rarely throw fetch failed
; when the network is busy, error occurs more frequent.
from undici.
Facing a similar issue
from undici.
same issue, anyone know the solution?
from undici.
if the internet connectivity was the issue, then why curl always work and never throw timeout?
from undici.
it seems this error only appear in certain environment or device? it's hard to reproduce but I think the bug really exists
someone already describe the same issue here too #2990
from undici.
or in certain host? I faced this issue when trying to fetch telegram api
from undici.
here's the endpoint that I try to fetch
curl "https://api.telegram.org/bot7003873933:AAFKl0LwWViMJIA34-qjbTh7nZwcNQr2hFs/getFile?file_id=CAACAgEAAxUAAWYT6IXJGTzY4S96PCbyqyO7fBXXAAIJEgACkweVC56njKMcTovTNAQ"
from undici.
Can you provide an
Minimum Reproducible Example to support you better?
from undici.
I've provided the Minimum Reproducible Example on my Gist, as you suggested.
If you have a strong or reliable internet connection, consider simulating slow connectivity to see if the error replicates. After all, ETIMEDOUT errors are more likely to occur under limited bandwidth conditions.
Interestingly, while fetch sometimes throws this error, curl seems to be able to avoid it in this scenario.
from undici.
Hmm, this does not seem like an undici
error per se but rather a different way of handling connect timeouts.
The errors shown by the example and the roots of the issue mostly to the initial TCP connection (including TLS), meaning that undici
timed out before the server could finish the initial connect operation.
You can attempt to extend the overall timeout while creating a custom Agent
(See https://undici.nodejs.org/#/docs/api/Client?id=parameter-clientoptions) and test if that solves the timeout issue, which seems related directly to the network conditions.
As well, you can wrap it with the RetryAgent
to automatically retry upon this errors.
from undici.
in the docs it says:
bodyTimeout - Defaults to 300 seconds.
headersTimeout - Defaults to 300 seconds.
why it close the connection too early if the default was 300 seconds? does the node fetch use undici differently in the internal?
btw, this is unrelated question: why I can't access undici directly (require('undici')
) if it was used in fetch implementation of node? is there a way to expose it, so I can use the RetryAgent
class without installing undici dependency?
from undici.
The timeouts you mention are applied directly at http
level, meanwhile the timeout
I'm referring to, is linked to the TCP handshake; which by default is 10s
(lower than the body and headers).
Sadly no, you'll need to install undici
to make use of the RetryAgent
.
from undici.
Thanks for your assistance! It's confirmed that increasing the connection timeout resolved the issue in my scenario ^^
from undici.
I am able to reliably repro it when fetching too many urls at once. nodejs/node-core-utils#810
from undici.
Related Issues (20)
- Nightly tests are failing HOT 4
- publish autobahn test results on the docs site HOT 7
- Nightly tests are failing HOT 2
- Improve support for pre-shared sessions (PSK) HOT 3
- Request constructor: Failed to parse URL from ___ HOT 2
- Broken links in docs webpage HOT 2
- Failing JSON parsing in Node 22 HOT 13
- undici/types/index.d.ts:21:8: Type error TS1192: Module '"[email protected]/node_modules/undici/types/interceptors"' has no default export HOT 6
- Node 22.3.0 regression: undici sends invalid origin header in some cases HOT 2
- fetch arrayBuffer() leaks random data from process memory HOT 18
- build: husky install is deprecated HOT 1
- Ability to externalize WASM was broken HOT 11
- Measure request latency HOT 3
- dns round-robin interceptor + cache HOT 3
- async dispatch handler helper
- Cannot convert argument to a ByteString because the character at index 46 has a value of 65286 which is greater than 255 HOT 2
- Undici.Request and AbortController doesn't work well HOT 22
- The RetryHandler receives a duplicate body when the server does not support Range requests. HOT 11
- `Dispatcher.compose` doesn't return a true dispatcher HOT 9
- Back-pressure doesn't work with sub dispatches
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from undici.