()
| 370 | } |
| 371 | |
| 372 | #updateStaleTimeout(): void { |
| 373 | this.#clearStaleTimeout() |
| 374 | const staleTime = resolveStaleTime( |
| 375 | this.options.staleTime, |
| 376 | this.#currentQuery, |
| 377 | ) |
| 378 | |
| 379 | if ( |
| 380 | environmentManager.isServer() || |
| 381 | this.#currentResult.isStale || |
| 382 | !isValidTimeout(staleTime) |
| 383 | ) { |
| 384 | return |
| 385 | } |
| 386 | |
| 387 | const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) |
| 388 | |
| 389 | // The timeout is sometimes triggered 1 ms before the stale time expiration. |
| 390 | // To mitigate this issue we always add 1 ms to the timeout. |
| 391 | const timeout = time + 1 |
| 392 | |
| 393 | this.#staleTimeoutId = timeoutManager.setTimeout(() => { |
| 394 | if (!this.#currentResult.isStale) { |
| 395 | this.updateResult() |
| 396 | } |
| 397 | }, timeout) |
| 398 | } |
| 399 | |
| 400 | #computeRefetchInterval() { |
| 401 | return ( |
no test coverage detected