Giter VIP home page Giter VIP logo

Comments (15)

mcollina avatar mcollina commented on July 19, 2024

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.

guotie avatar guotie commented on July 19, 2024

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.

smisra3 avatar smisra3 commented on July 19, 2024

Facing a similar issue

from undici.

ahmadxgani avatar ahmadxgani commented on July 19, 2024

same issue, anyone know the solution?

from undici.

ahmadxgani avatar ahmadxgani commented on July 19, 2024

if the internet connectivity was the issue, then why curl always work and never throw timeout?

from undici.

RealYukiSan avatar RealYukiSan commented on July 19, 2024

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.

ahmadxgani avatar ahmadxgani commented on July 19, 2024

or in certain host? I faced this issue when trying to fetch telegram api

from undici.

ahmadxgani avatar ahmadxgani commented on July 19, 2024

here's the endpoint that I try to fetch

curl "https://api.telegram.org/bot7003873933:AAFKl0LwWViMJIA34-qjbTh7nZwcNQr2hFs/getFile?file_id=CAACAgEAAxUAAWYT6IXJGTzY4S96PCbyqyO7fBXXAAIJEgACkweVC56njKMcTovTNAQ"

from undici.

metcoder95 avatar metcoder95 commented on July 19, 2024

Can you provide an
Minimum Reproducible Example to support you better?

from undici.

RealYukiSan avatar RealYukiSan commented on July 19, 2024

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.

metcoder95 avatar metcoder95 commented on July 19, 2024

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.

RealYukiSan avatar RealYukiSan commented on July 19, 2024

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.

metcoder95 avatar metcoder95 commented on July 19, 2024

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.

RealYukiSan avatar RealYukiSan commented on July 19, 2024

Thanks for your assistance! It's confirmed that increasing the connection timeout resolved the issue in my scenario ^^

from undici.

KhafraDev avatar KhafraDev commented on July 19, 2024

I am able to reliably repro it when fetching too many urls at once. nodejs/node-core-utils#810

from undici.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.