Skip to content
Source
Sign inSign up
TanStack/query

feat(query-core)!: make server timers opt-in #12715

DraftTkDodowants to merge 5 commits intoquery-v6 fromrefs/pull/12715/headopened View on GitHub

TkDodocommented

🎯 Changes

Request-scoped SSR clients can schedule GC timers when shared query options set a finite gcTime. In Node.js, those timers can retain the request's async context after the response completes. See the v6 discussion and the original report.

Disable GC, stale notifications, polling, and retries on the server by default. A long-lived server can opt in at startup with the existing timeoutManager.setTimeoutProvider() API. The provider applies to all clients using that manager. The server defaults stay at gcTime: Infinity and zero retries, so apps still configure finite eviction and retries explicitly.

With timers disabled, a failed operation rejects with its original error. Persistence can still schedule its own delays.

Verification

  • Server timer tests cover finite GC for queries and mutations, subscribed observers, and explicit retries with and without a custom provider.
  • The new cases exposed the old GC, observer, and retry behavior on the v6 base.
  • Query Core and persistence tests, types, and lint passed. React and Preact library tests and docs link checks also passed.
  • Preview Size Limit comparison is pending.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).
    1. Pushedc63e5ea

    2. Pusheddd91b92

    3. Pushed2108823

    4. Pushedb6254ad

Sign in to join this conversation.