T
TanStack•11mo ago
xenial-black

Does tanstack-query or fetch have any kind of default request timeout?

We have a particularly slow backend today, and seems our frontend is fairly consistently giving up and retrying after 20 seconds. The backend on the other-hand seem to continue what it's doing and finish whatever that was, but it can take over a minute sometimes. I'm assuming there's something timing out somewhere, and it seems to happen on the frontend, but I can't seem to find any information about a default request timeout or how to configure one for fetch, tanstack-query, or browsers. Anyone know anything about this topic? I know you can use an AbortController to introduce a timeout, but, we have no such thing anywhere.
4 Replies
xenial-black
xenial-blackOP•11mo ago
Starting to think there must be something between our frontend and our backend that our dev-team is not aware of. Have sent a question to our infra team, but yeah... would be great if someone here could rule out any timeouts in fetch or react-query at least. I'm pretty sure there's no timeouts there, but would be great to get it confirmed 😛
like-gold
like-gold•11mo ago
Honestly, I'd always set up fetch requests to return as fast as possible. If you have long running backend work, I'd set up a background task/job queue and fast return with a pending status and a job id so you can subscribe to the job and get thr data when it's ready. Having long running pending HTTP requests is a nightmare I'd prioritise this across all your stack as a user facing issue myself
like-gold
like-gold•11mo ago
Important Defaults | TanStack Query React Docs
Out of the box, TanStack Query is configured with aggressive but sane defaults. Sometimes these defaults can catch new users off guard or make learning/debugging difficult if they are unknown by the u...
like-gold
like-gold•11mo ago
Queries that fail are silently retried 3 times, with exponential backoff delay before capturing and displaying an error to the UI. To change this, you can alter the default retry and retryDelay options for queries to something other than 3 and the default exponential backoff function.

Did you find this page helpful?