From 5d3962872768449e8bb71927ac7f831492efc3ac Mon Sep 17 00:00:00 2001 From: Darshankumar Joshi Date: Sun, 22 Feb 2026 13:24:52 +0100 Subject: [PATCH] fix(query-core): remove isServer check from refetch interval logic Fixes #10139 ## Problem The isServer check in QueryObserver's #updateStaleTimeout and #updateRefetchInterval methods prevents refetch intervals from running in environments where window is undefined, such as: - Chrome extensions - VSCode extensions - Electron renderer processes This occurs because isServer is defined as: typeof window === 'undefined' || 'Deno' in globalThis These environments are NOT servers but have no window global, causing the isServer check to incorrectly skip interval setup. ## Solution Remove the isServer check from both timeout methods. This is safe because: 1. QueryObserver subscriptions only run on the client (they execute in React effects/useSyncExternalStore, never on the server) 2. The isServer check is redundant - if code reaches these methods, we're already on the client 3. Other guards (enabled check, timeout validation) provide sufficient protection ## Impact - Fixes refetch intervals in Chrome/VSCode extensions - Maintains existing behavior for normal browser environments - No server-side impact (code never runs on server anyway) Suggested by @TkDodo in discussion #4018 --- packages/query-core/src/queryObserver.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/query-core/src/queryObserver.ts b/packages/query-core/src/queryObserver.ts index 463407a0737..1546698439b 100644 --- a/packages/query-core/src/queryObserver.ts +++ b/packages/query-core/src/queryObserver.ts @@ -358,7 +358,7 @@ export class QueryObserver< this.#currentQuery, ) - if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) { + if (this.#currentResult.isStale || !isValidTimeout(staleTime)) { return } @@ -389,7 +389,6 @@ export class QueryObserver< this.#currentRefetchInterval = nextInterval if ( - isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0