fix(query-core): honour the fetchStatus filter in isFetching/useIsFetching by Apu-Emdad · Pull Request #12024 · TanStack/query · GitHub
Skip to content

fix(query-core): honour the fetchStatus filter in isFetching/useIsFetching - #12024

Open
Apu-Emdad wants to merge 2 commits into
TanStack:mainfrom
Apu-Emdad:fix/isFetching-honour-fetchStatus-filter
Open

Apu-Emdad wants to merge 2 commits into
TanStack:mainfrom
Apu-Emdad:fix/isFetching-honour-fetchStatus-filter

Conversation

@Apu-Emdad

@Apu-Emdad Apu-Emdad commented Oct 14, 2026 •

Copy link
Copy Markdown

Re-opened from #11997, which closed when I deleted my fork by mistake. Same commits, no changes.

Fixes #11984

QueryClient.isFetching spread the caller's filters and then unconditionally overwrote fetchStatus with 'fetching', so a typed, documented fetchStatus filter (e.g. 'paused') type-checked but was silently discarded. useIsFetching forwards to this method, so it was affected too. QueryCache.findAll already honours the same filter correctly, which is what made the gap easy to miss.

This defaults fetchStatus to 'fetching' only when the caller didn't pass one, matching the documented behaviour and findAll's own handling (resolution option 2 from the issue).

  • Updated the method's JSDoc.
  • Added a regression test that mocks the browser offline so a real query lands in fetchStatus: 'paused', then checks isFetching(), isFetching({fetchStatus:'paused'}) and isFetching({fetchStatus:'idle'}) all return the right counts.
  • Added a changeset (patch on @tanstack/query-core).

Checks

  • pnpm nx run @tanstack/query-core:test:lib — 1600/1600 passed, 0 type errors
  • pnpm nx run @tanstack/react-query:test:lib -- useIsFetching — 5/5 passed
  • pnpm nx affected --target=test:eslint --base=main — clean
  • pnpm nx affected --target=test:types --base=main — clean

Summary by CodeRabbit

  • Bug Fixes
    • QueryClient.isFetching now respects the supplied fetch-status filter, including paused queries. When no filter is provided, it continues to count queries that are fetching.

…ching

QueryClient.isFetching spread the caller's filters and then
unconditionally overwrote fetchStatus with 'fetching', so a typed,
documented fetchStatus filter (e.g. 'paused') type-checked but was
silently discarded. useIsFetching forwards to this method, so it was
affected too. QueryCache.findAll already honours the same filter
correctly, which is what made the gap easy to miss.

Default fetchStatus to 'fetching' only when the caller didn't pass
one, matching the documented behaviour and findAll's own handling.

Fixes TanStack#11984
…ching

Spreading the filters after the default let an explicit
`fetchStatus: undefined` override it, so isFetching counted every
query. Apply the default after the spread instead.
@changeset-bot

changeset-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/query/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a6580a25-4fec-4b07-85d8-7c1d806fb904
📥 Commits

Reviewing files that changed from the base of the PR and between a8af0e2 and ed869f3.

📒 Files selected for processing: 3
  • .changeset/isFetching-honour-fetchStatus-filter.md
  • packages/query-core/src/__tests__/queryClient.test.tsx
  • packages/query-core/src/queryClient.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.isFetching now uses a supplied fetchStatus filter and defaults to 'fetching' when the filter is nullish. Tests cover paused queries and the default, explicit undefined, and idle filters. A patch changeset records the change for @tanstack/query-core.

Changes: fetchStatus filter behavior

Layer / File(s) Summary
Apply and verify fetchStatus filters
packages/query-core/src/queryClient.ts, packages/query-core/src/__tests__/queryClient.test.tsx, .changeset/isFetching-honour-fetchStatus-filter.md
QueryClient.isFetching uses the supplied non-nullish fetchStatus or defaults to 'fetching'. Documentation describes the filter behavior. Tests cover paused, default, explicit undefined, and idle cases. The changeset declares a patch release.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sukvvon

Merge Risk: ⚪ Minimal · up to ed869

isFetching honors the requested status while retaining fetching as its default. The supplied tests cover the relevant filter cases, and no merge-blocking issue is identified.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main fix: making the fetchStatus filter work in isFetching and useIsFetching.
Description check Passed The description is mostly complete. It explains the defect, implementation, regression test, release impact, changeset, and validation results. It does not reproduce the template's Changes, Checklist,…
Linked Issues check Passed Issue [#11984] requires QueryClient.isFetching to honor fetchStatus and default to 'fetching' when no value is supplied. queryClient.ts now spreads filters and applies `filters?.fetchStatus ??…
Out of Scope Changes check Passed The changes are limited to the [#11984] fix: the QueryClient.isFetching implementation, its JSDoc, a focused regression test, and a package changeset. No unrelated production behavior or unrelated f…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ 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.

QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore it

1 participant