Skip to content

fix(query-core): resetQueries now preserves the queries matched before query.reset() changes their state. - #11211

Merged
TkDodo merged 2 commits into
mainfrom
feature/reset-queries
Aug 17, 2026
Merged

fix(query-core): resetQueries now preserves the queries matched before query.reset() changes their state.#11211
TkDodo merged 2 commits into
mainfrom
feature/reset-queries

Conversation

@TkDodo

@TkDodo TkDodo commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

closes #10705

Summary by CodeRabbit

  • Bug Fixes

    • Improved resetQueries so it consistently resets and refetches the queries originally selected, even when their state changes during the reset.
    • Ensured active queries with errors are correctly refetched and updated with fresh data.
  • Tests

    • Added coverage for state-dependent query selection, resetting, and refetching behavior.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bd5bfdc0-ef04-4bf8-8ecb-da0b3f72b56d

📥 Commits

Reviewing files that changed from the base of the PR and between c6fc17c and 4cfcbba.

📒 Files selected for processing (3)
  • .changeset/swift-actors-brush.md
  • packages/query-core/src/__tests__/queryClient.test.tsx
  • packages/query-core/src/queryClient.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/query-core/src/queryClient.ts
  • packages/query-core/src/tests/queryClient.test.tsx
  • .changeset/swift-actors-brush.md

Included review availability: Your plan includes up to 10 reviews per rolling hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

resetQueries now preserves its initial query selection when resetting state can change predicate results. A regression test covers error-state selection, reset, active refetch, and cached data. A patch changeset documents the behavior.

Changes

resetQueries selection

Layer / File(s) Summary
Capture initial selection and validate refetch behavior
packages/query-core/src/queryClient.ts, packages/query-core/src/__tests__/queryClient.test.tsx, .changeset/swift-actors-brush.md
resetQueries captures matched queries before reset and refetches only that set. The test verifies predicate-based selection and successful cached data. The changeset records the patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4cfcb

The PR makes a localized resetQueries behavior fix with accompanying tests; no actionable merge-blocking risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only references a closing issue and omits the required changes, checklist, testing, and release impact sections. Add the required template sections, describe the fix and motivation, complete the checklist, and confirm the changeset and test status.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary resetQueries behavior change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/reset-queries

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

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 17, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4cfcbba

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 7m 37s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 44s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-17 12:27:04 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

🟨 Minor bumps

Package Version Reason
@tanstack/query-core 5.101.4 → 5.102.0 Changeset
@tanstack/angular-query-experimental 5.101.4 → 5.102.0 Dependent
@tanstack/angular-query-persist-client 5.101.4 → 5.102.0 Dependent
@tanstack/eslint-plugin-query 5.101.4 → 5.102.0 Dependent
@tanstack/preact-query 5.101.4 → 5.102.0 Dependent
@tanstack/preact-query-devtools 5.101.4 → 5.102.0 Dependent
@tanstack/preact-query-persist-client 5.101.4 → 5.102.0 Dependent
@tanstack/query-async-storage-persister 5.101.4 → 5.102.0 Dependent
@tanstack/query-broadcast-client-experimental 5.101.4 → 5.102.0 Dependent
@tanstack/query-devtools 5.101.4 → 5.102.0 Dependent
@tanstack/query-persist-client-core 5.101.4 → 5.102.0 Dependent
@tanstack/query-sync-storage-persister 5.101.4 → 5.102.0 Dependent
@tanstack/react-query 5.101.4 → 5.102.0 Dependent
@tanstack/react-query-devtools 5.101.4 → 5.102.0 Dependent
@tanstack/react-query-next-experimental 5.101.4 → 5.102.0 Dependent
@tanstack/react-query-persist-client 5.101.4 → 5.102.0 Dependent
@tanstack/solid-query 5.101.4 → 5.102.0 Dependent
@tanstack/solid-query-devtools 5.101.4 → 5.102.0 Dependent
@tanstack/solid-query-persist-client 5.101.4 → 5.102.0 Dependent
@tanstack/vue-query 5.101.4 → 5.102.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.11 → 0.2.12 Dependent
@tanstack/svelte-query 6.1.38 → 6.1.39 Dependent
@tanstack/svelte-query-devtools 6.1.38 → 6.1.39 Dependent
@tanstack/svelte-query-persist-client 6.1.38 → 6.1.39 Dependent
@tanstack/vue-query-devtools 6.1.38 → 6.1.39 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Aug 17, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 4cfcbba

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.27 KB (+0.16% 🔺)
react minimal 9.22 KB (+0.19% 🔺)

@TkDodo
TkDodo merged commit 326aaf1 into main Aug 17, 2026
9 checks passed
@TkDodo
TkDodo deleted the feature/reset-queries branch August 17, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resetQueries method does not trigger refetch on errored queries

1 participant