Zirnael
Zirnael

Reputation: 13

Does the refetch interval timer begin at the start of a request or after the request completes?

If refetchInterval is set to 10 seconds in useQuery, and a given request takes 2 seconds to complete, will the next request be initiated 10 seconds after the start of the previous request, or 10 seconds after the previous request completes?

In other words, will there be 10 seconds or 12 seconds between the start of consecutive requests?

In my project the request can take substantial amount of time, even up to 5-10 seconds. Understanding the behavior would help me to pick correct refetchInterval value

I looked at the documentation of React Query, but it isn't entirely clear on this point. If set to a number, all queries will continuously refetch at this frequency in milliseconds

Upvotes: 1

Views: 39

Answers (1)

TkDodo
TkDodo

Reputation: 28998

It will be 10 seconds after the previous request completes. The timer re-starts every time when data is put into the cache.

Upvotes: 0

Related Questions