Skip to content

Tanstack Query refetch does not work in certain environments (vscode extension, chrome extension) #10139

@JustinGrote

Description

@JustinGrote

Describe the bug

Issue

This isServer check prevents the queries from running in these environments, mistakenly seeing them as servers anywhere globalThis.window is undefined.

export const isServer = typeof window === 'undefined' || 'Deno' in globalThis

Related Discussion

Workarounds

  • Use queryClient.invalidateQueries in a setInterval
  • [Maybe?] Put a "dummy" item into globalthis.window so that it isn't seen as a server. WARNING: This could have major unexpected side effects.

Proposed Fix

(by @TkDodo)
Decouple setInterval calls from isServer checks. None if this code runs on the server anyways, because subscriptions are only created on the client (they run in effects / useSyncExternalStore, so not on the server)

Your minimal, reproducible example

See above

Steps to reproduce

See above

Expected behavior

See above

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Chrome extensions and vscode extensions

Tanstack Query adapter

vanilla

TanStack Query version

v5.90.20

TypeScript version

v5.8.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions