Skip to content
Source
Sign inSign up
TanStack/db

bug [upstream]: queryCollection does not refetch in non-windowed environments (Chrome extension, vscode extension) #1250

Send to my agent
ClosedJustinGrote(GitHub profile, opens in a new tab) opened this issue 3 comments
  • I've validated the bug against the latest version of DB packages

Describe the bug An upstream issue in Tanstack Query prevents Tanstack DB from operating correctly in environments missing

To Reproduce Steps to reproduce the behavior:

Create any collection in an environment where globalThis.window is undefined

Expected behavior Refetches occur

Additional context (From @KyleAMathews)

Root cause: TanStack Query's QueryObserver.#updateRefetchInterval() has a hard guard:

if (isServer ...) { return }

where isServer = typeof window === 'undefined' 'Deno' in globalThis. In a VS Code extension (Node.js), window is undefined so the refetch interval timer is never created.

TanStack Query's own docs: The recommended non-browser setup (e.g., React Native guide) uses focusManager.setFocused() and onlineManager.setOnline(). But those don't help here — the isServer guard fires before the focusManager.isFocused() check, so it blocks entirely.

Upstream status: This is acknowledged as a limitation in TanStack/query Discussion #4018. Maintainer TkDodo said the isServer check should be decoupled from setInterval availability, but no fix has landed — still present on main.

Given this, the proper fix should be at the QueryClient configuration level where queryCollectionOptions creates the QueryObserver. Since isServer is a module-level constant we can import from @tanstack/query-core, the cleanest approach is: when isServer && refetchInterval is configured, set refetchIntervalInBackground: true and manage a simple interval ourselves using observer.refetch() — the public API TanStack Query provides for exactly this purpose.

  1. Hi @JustinGrote,

    Since this is a problem with TanStack Query and it seems that there are some recently opened PRs for solving it i would rather wait for those fixes in TanStack Query rather than implementing workarounds in TanStack DB. Please keep me in the loop if there is any progress on the TanStack Query issue. Hopefully it gets solves soon and then we can also close this issue.

  2. kevin-dp(GitHub profile, opens in a new tab) added labelswontfix

  3. Closing this to match the existing decision. The behavior is owned by TanStack Query's server-environment refetch scheduling; we don't want to carry a TanStack DB workaround here.

  4. Clarification: this matches the existing wontfix label and maintainer decision.

Sign in to join this conversation.