Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#1,250 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Inizia da queryCollectionOptions, dove viene creato il QueryObserver, e analizza il comportamento non basato sulle finestre descritto nell’issue upstream di TanStack Query. Riproducilo con globalThis.window non definito e verifica che gli intervalli di refetch configurati invochino observer.refetch() in ambienti simili a Chrome o VS Code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

wontfix
  • 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.

Lingua principale
TypeScript
Stelle
3.9k
Fork
272
Merge medio
1g 1h
PR unite (30g)
210

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/db

Tutte le issue di TanStack/db

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.