MCPcopy Index your code
hub / github.com/TanStack/query / #updateStaleTimeout

Method #updateStaleTimeout

packages/query-core/src/queryObserver.ts:353–375  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351 }
352
353 #updateStaleTimeout(): void {
354 this.#clearStaleTimeout()
355 const staleTime = resolveStaleTime(
356 this.options.staleTime,
357 this.#currentQuery,
358 )
359
360 if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
361 return
362 }
363
364 const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime)
365
366 // The timeout is sometimes triggered 1 ms before the stale time expiration.
367 // To mitigate this issue we always add 1 ms to the timeout.
368 const timeout = time + 1
369
370 this.#staleTimeoutId = timeoutManager.setTimeout(() => {
371 if (!this.#currentResult.isStale) {
372 this.updateResult()
373 }
374 }, timeout)
375 }
376
377 #computeRefetchInterval() {
378 return (

Callers 2

setOptionsMethod · 0.95
#updateTimersMethod · 0.95

Calls 6

#clearStaleTimeoutMethod · 0.95
updateResultMethod · 0.95
resolveStaleTimeFunction · 0.90
isValidTimeoutFunction · 0.90
timeUntilStaleFunction · 0.90
setTimeoutMethod · 0.80

Tested by

no test coverage detected