Skip to content

fix(query-core): honour the status filter in isMutating/useIsMutating - #12318

Open
praveenganthp wants to merge 1 commit into
TanStack:mainfrom
praveenganthp:fix/is-mutating-honour-status-filter
Open

praveenganthp wants to merge 1 commit into
TanStack:mainfrom
praveenganthp:fix/is-mutating-honour-status-filter

Conversation

@praveenganthp

@praveenganthp praveenganthp commented Oct 24, 2026 •

Copy link
Copy Markdown

🎯 Changes

Previously, QueryClient.isMutating and framework useIsMutating hooks unconditionally overwrote status: 'pending' onto mutation filters:

return this.#mutationCache.findAll({ ...filters, status: 'pending' }).length

Even though filters accepts MutationFilters (which supports status?: MutationStatus), passing a custom status filter (such as 'success', 'error', or 'idle') was silently ignored and overwritten by 'pending'.

This PR updates isMutating and useIsMutating across @tanstack/query-core, @tanstack/react-query, @tanstack/preact-query, and @tanstack/vue-query so caller-provided status filters are honoured, defaulting to 'pending' when omitted:

status: filters?.status ?? 'pending'

Framework wrappers for solid, svelte, lit, and angular delegate directly to queryClient.isMutating(filters) under the hood and automatically inherit this fix.

  • Updated implementation and JSDoc in @tanstack/query-core, @tanstack/react-query, @tanstack/preact-query, and @tanstack/vue-query.
  • Added regression tests in @tanstack/query-core and @tanstack/react-query.
  • Added patch changeset.

✅ 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).

Summary by CodeRabbit

  • Bug Fixes
    • Mutation-counting APIs now honor an explicitly provided status filter. Without one, they continue to count pending mutations by default.
    • Added coverage for filtering mutations by pending, successful, and errored status.

@changeset-bot

changeset-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2af0cbd

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

This PR includes changesets to release 24 packages
Name Type
@tanstack/query-core Patch
@tanstack/react-query Patch
@tanstack/preact-query Patch
@tanstack/vue-query Patch
@tanstack/angular-query-experimental Patch
@tanstack/lit-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/solid-query Patch
@tanstack/svelte-query Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/react-query-persist-client Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/vue-query-devtools Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/solid-query-persist-client Patch
@tanstack/svelte-query-persist-client Patch
@tanstack/eslint-plugin-query Patch

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

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9e42537 and 2af0cbd.

Files selected for processing: 7
  • .changeset/isMutating-honour-status-filter.md
  • packages/preact-query/src/useMutationState.ts
  • packages/query-core/src/__tests__/queryClient.test.tsx
  • packages/query-core/src/queryClient.ts
  • packages/react-query/src/__tests__/useMutationState.test.tsx
  • packages/react-query/src/useMutationState.ts
  • packages/vue-query/src/useMutationState.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

QueryClient.isMutating and the Preact, React, and Vue useIsMutating hooks now honor a supplied status filter. When no status is supplied, they use pending. Tests and a changeset cover the update.

Changes: Mutation status filters

Layer / File(s) Summary
Core mutation status filtering
packages/query-core/src/queryClient.ts, packages/query-core/src/__tests__/queryClient.test.tsx
QueryClient.isMutating now preserves a supplied status filter and defaults to pending. Tests check counts for pending, successful, and errored mutations.
Framework hook status filtering
packages/preact-query/src/useMutationState.ts, packages/react-query/src/useMutationState.ts, packages/vue-query/src/useMutationState.ts, packages/react-query/src/__tests__/useMutationState.test.tsx, .changeset/isMutating-honour-status-filter.md
The three useIsMutating hooks now preserve supplied status filters and default to pending. Documentation, React tests, and a changeset describe or validate this behavior.

Priority: Normal

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

Change: Bug fix

Suggested reviewers: sukvvon, tkdodo, damianosipiuk

Merge Risk: Minimal · up to 2af0c

The status-filter change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: honoring the status filter in isMutating and useIsMutating.
Description check Passed The description follows the required template, explains the behavior change and motivation, identifies affected packages, documents tests and release impact, and includes the required checklist select…
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.
Full details: Description check

Explanation

The description follows the required template, explains the behavior change and motivation, identifies affected packages, documents tests and release impact, and includes the required checklist selections.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

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

This branch has not been deployed

No deployments
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.

1 participant