2

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?

Divya Konda
  • 1,427
  • 2
  • 10
  • 11

1 Answers1

2

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)

mwilson
  • 12,295
  • 7
  • 55
  • 95