Skip to content
Source
Sign inSign up
TanStack/query

fix(query-core): clear GC timers for removed cache entries #12683

MergedTkDodomerged 1 commit intomain fromrefs/pull/12683/headmerged by TkDodo View on GitHub

TkDodocommented

🎯 Changes

Refs #12561.

  • Clear mutation GC timers when mutations leave the cache. Running mutations can still finish.
  • Check cache membership before fetch or observer cleanup schedules GC. Cancel a query's fetch before clearing its timer so synchronous abort listeners cannot leave a timer behind.
  • Remove the obsolete workaround from the SSR guides.

All six regression cases fail on main and pass with this change. The query-core suite passes all 1,653 tests. The full local PR suite passed 643 tasks. Nine unchanged Next.js example and integration builds failed with SecurityFatalError from their installed Next.js versions.

Preview Size Limit passed for both Brotli-compressed React bundles. The full bundle grew by 44 B (+0.36%) and the minimal bundle by 34 B (+0.38%). Percentages use the exact baseline byte counts.

✅ 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. 🦋 Changeset detected

      Latest commit: f50936e1a761fd3b106521fbbb5e4b72b42616f3

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 26 packages
      NameType
      @tanstack/query-corePatch
      @tanstack/angular-queryPatch
      @tanstack/lit-queryPatch
      @tanstack/preact-queryPatch
      @tanstack/query-async-storage-persisterPatch
      @tanstack/query-broadcast-client-experimentalPatch
      @tanstack/query-devtoolsPatch
      @tanstack/query-persist-client-corePatch
      @tanstack/query-sync-storage-persisterPatch
      @tanstack/react-queryPatch
      @tanstack/solid-queryPatch
      @tanstack/svelte-queryPatch
      @tanstack/vue-queryPatch
      @tanstack/angular-query-devtoolsPatch
      @tanstack/angular-query-persist-clientPatch
      @tanstack/preact-query-devtoolsPatch
      @tanstack/preact-query-persist-clientPatch
      @tanstack/react-query-devtoolsPatch
      @tanstack/solid-query-devtoolsPatch
      @tanstack/svelte-query-devtoolsPatch
      @tanstack/vue-query-devtoolsPatch
      @tanstack/react-query-persist-clientPatch
      @tanstack/solid-query-persist-clientPatch
      @tanstack/svelte-query-persist-clientPatch
      @tanstack/react-query-next-experimentalPatch
      @tanstack/eslint-plugin-queryPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. Explain Change →

      Caution

      Review failed

      The pull request is closed.

      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share

    3. tanstack-source added labelsbug

    4. 🚀 Changeset Version Preview

      1 package(s) bumped directly, 25 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/query-core5.108.3 → 5.108.4Changeset
      @tanstack/angular-query5.108.3 → 5.108.4Dependent
      @tanstack/angular-query-devtools5.108.3 → 5.108.4Dependent
      @tanstack/angular-query-persist-client5.108.3 → 5.108.4Dependent
      @tanstack/eslint-plugin-query5.108.3 → 5.108.4Dependent
      @tanstack/lit-query0.2.43 → 0.2.44Dependent
      @tanstack/preact-query5.108.3 → 5.108.4Dependent
      @tanstack/preact-query-devtools5.108.3 → 5.108.4Dependent
      @tanstack/preact-query-persist-client5.108.3 → 5.108.4Dependent
      @tanstack/query-async-storage-persister5.108.3 → 5.108.4Dependent
      @tanstack/query-broadcast-client-experimental5.108.3 → 5.108.4Dependent
      @tanstack/query-devtools5.108.3 → 5.108.4Dependent
      @tanstack/query-persist-client-core5.108.3 → 5.108.4Dependent
      @tanstack/query-sync-storage-persister5.108.3 → 5.108.4Dependent
      @tanstack/react-query5.108.3 → 5.108.4Dependent
      @tanstack/react-query-devtools5.108.3 → 5.108.4Dependent
      @tanstack/react-query-next-experimental5.108.3 → 5.108.4Dependent
      @tanstack/react-query-persist-client5.108.3 → 5.108.4Dependent
      @tanstack/solid-query5.108.3 → 5.108.4Dependent
      @tanstack/solid-query-devtools5.108.3 → 5.108.4Dependent
      @tanstack/solid-query-persist-client5.108.3 → 5.108.4Dependent
      @tanstack/svelte-query6.4.6 → 6.4.7Dependent
      @tanstack/svelte-query-devtools6.4.6 → 6.4.7Dependent
      @tanstack/svelte-query-persist-client6.4.6 → 6.4.7Dependent
      @tanstack/vue-query5.108.3 → 5.108.4Dependent
      @tanstack/vue-query-devtools6.4.6 → 6.4.7Dependent
    5. View your CI Pipeline Execution ↗ for commit f50936e1a761fd3b106521fbbb5e4b72b42616f3

      CommandStatusDurationResult
      nx run-many --target=build --exclude=examples/*...✅ Succeeded3sView ↗
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded2m 8sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-11-23 11:36:22 UTC

    6. More templates

      @tanstack/angular-query

      npm i https://pkg.pr.new/@tanstack/angular-query@12683

      @tanstack/angular-query-devtools

      npm i https://pkg.pr.new/@tanstack/angular-query-devtools@12683

      @tanstack/angular-query-persist-client

      npm i https://pkg.pr.new/@tanstack/angular-query-persist-client@12683

      @tanstack/eslint-plugin-query

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@12683

      @tanstack/lit-query

      npm i https://pkg.pr.new/@tanstack/lit-query@12683

      @tanstack/preact-query

      npm i https://pkg.pr.new/@tanstack/preact-query@12683

      @tanstack/preact-query-devtools

      npm i https://pkg.pr.new/@tanstack/preact-query-devtools@12683

      @tanstack/preact-query-persist-client

      npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@12683

      @tanstack/query-async-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@12683

      @tanstack/query-broadcast-client-experimental

      npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@12683

      @tanstack/query-core

      npm i https://pkg.pr.new/@tanstack/query-core@12683

      @tanstack/query-devtools

      npm i https://pkg.pr.new/@tanstack/query-devtools@12683

      @tanstack/query-persist-client-core

      npm i https://pkg.pr.new/@tanstack/query-persist-client-core@12683

      @tanstack/query-sync-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@12683

      @tanstack/react-query

      npm i https://pkg.pr.new/@tanstack/react-query@12683

      @tanstack/react-query-devtools

      npm i https://pkg.pr.new/@tanstack/react-query-devtools@12683

      @tanstack/react-query-next-experimental

      npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@12683

      @tanstack/react-query-persist-client

      npm i https://pkg.pr.new/@tanstack/react-query-persist-client@12683

      @tanstack/solid-query

      npm i https://pkg.pr.new/@tanstack/solid-query@12683

      @tanstack/solid-query-devtools

      npm i https://pkg.pr.new/@tanstack/solid-query-devtools@12683

      @tanstack/solid-query-persist-client

      npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@12683

      @tanstack/svelte-query

      npm i https://pkg.pr.new/@tanstack/svelte-query@12683

      @tanstack/svelte-query-devtools

      npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@12683

      @tanstack/svelte-query-persist-client

      npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@12683

      @tanstack/vue-query

      npm i https://pkg.pr.new/@tanstack/vue-query@12683

      @tanstack/vue-query-devtools

      npm i https://pkg.pr.new/@tanstack/vue-query-devtools@12683

      commit: f50936e

    7. size-limit report 📦

      PathSize
      react full11.96 KB (+0.37% 🔺)
      react minimal8.71 KB (+0.39% 🔺)
    8. TkDodo linked this to fix #12561

    9. TkDodo closed this

    10. TkDodo reopened this

    11. TkDodo merged this89bb082

    12. TkDodo closed this

Sign in to join this conversation.