Capítulo 61 de 80
Every timer the library uses internally — staleTime/gcTime expiry, retries, throttling, debouncing — routes through timeoutManager, swappable via setTimeoutProvider for apps with thousands of concurrent queries hitting event-loop timer pressure, or needing delays past the browser's ~24-day setTimeout cap.
setTimeout/setInterval — no configuration needed for typical apps.setTimeoutProvider(provider): swaps in a custom TimeoutProvider (setTimeout/clearTimeout/setInterval/clearInterval implementations) — must be called before creating a QueryClient or any queries, since different providers can't cancel each other's timers, and consistency across the app depends on always using the same one.TimeoutProvider is the extension point for that. It's also the way to exceed the ~24-day maximum delay of the platform's native setTimeout.TimeoutProvider's timer IDs can be a number or any object coercible to one via Symbol.toPrimitive — accommodates runtimes like Node.js, whose native setTimeout returns a Timeout object rather than a plain number.setTimeout(callback, delayMs)/clearTimeout(id) and setInterval(callback, intervalMs)/clearInterval(id) — thin wrappers over whatever provider is currently configured, usable directly if code needs to schedule work through the same timer system the library itself uses.// Must run before creating the QueryClient
timeoutManager.setTimeoutProvider(new CustomTimeoutProvider())
export const queryClient = new QueryClient()
TimeoutProvider before constructing QueryClient, never after — a mid-app provider switch can't reconcile timers already scheduled under the old one.setTimeout delay cap — most apps never need it.gcTime/maxAge cap this manager's custom-provider escape hatch can work around.staleTime/gcTime, among the features implemented via this manager's timers.