Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How will timeout be determined when using fetch? [duplicate]

I have read a few questions and answers and found that we can not set timeout for a fetch request. In that case, what will determine the timeout of a fetch request? What if the server never responds to the fetch request? Is it expected that the fetch request is alive forever till server responds or client kills it?

like image 721
Divya Konda Avatar asked Dec 03 '25 10:12

Divya Konda


1 Answers

There isn't a magic number that's specific to the Fetch API. As a matter of fact, it's not even mentioned in the specification. However, what you should think about is the browser in which you're using. That may play a role in how long a given request is allowed to live (see this)

If you need to enforce a timeout, then I would suggest wrapping your fetch call within a custom timeout wrapper (example here)

like image 124
mwilson Avatar answered Dec 04 '25 22:12

mwilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!