MCPcopy Create free account
hub / github.com/TanStack/query / setTimeoutProvider

Method setTimeoutProvider

packages/query-core/src/timeoutManager.ts:75–102  ·  view source on GitHub ↗
(
    provider: TimeoutProvider<TTimerId>,
  )

Source from the content-addressed store, hash-verified

73 #providerCalled = false
74
75 setTimeoutProvider<TTimerId extends ManagedTimerId>(
76 provider: TimeoutProvider<TTimerId>,
77 ): void {
78 if (process.env.NODE_ENV !== 'production') {
79 if (this.#providerCalled && provider !== this.#provider) {
80 // After changing providers, `clearTimeout` will not work as expected for
81 // timeouts from the previous provider.
82 //
83 // Since they may allocate the same timeout ID, clearTimeout may cancel an
84 // arbitrary different timeout, or unexpected no-op.
85 //
86 // We could protect against this by mixing the timeout ID bits
87 // deterministically with some per-provider bits.
88 //
89 // We could internally queue `setTimeout` calls to `TimeoutManager` until
90 // some API call to set the initial provider.
91 console.error(
92 `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
93 { previous: this.#provider, provider },
94 )
95 }
96 }
97
98 this.#provider = provider
99 if (process.env.NODE_ENV !== 'production') {
100 this.#providerCalled = false
101 }
102 }
103
104 setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {
105 if (process.env.NODE_ENV !== 'production') {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected