QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore it
Les mainteneurs répondent en général sous 1 jour
@Apu-Emdad y travaille déjà.
Depuis le 14/10/2026.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript
- Domaine
- backend-api-design
Piste de recherche
Commencez dans packages/query-core/src/queryClient.ts, où l’issue signale la propagation et la surcharge de fetchStatus dans isFetching ; suivez ensuite la manière dont useIsFetching transmet ses filtres. Lisez les tests associés à QueryClient.isFetching et useIsFetching et ajoutez une couverture pour les cas en pause et inactifs signalés. Le travail est terminé lorsque l’API respecte le filtre ou le rejette dans ses types, avec un comportement et une documentation cohérents.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
QueryFilters has a fetchStatus?: FetchStatus field, and FetchStatus is 'fetching' | 'paused' | 'idle', so isFetching({ fetchStatus: 'paused' }) type-checks. It has no effect: QueryClient.isFetching spreads the filters it is given and then writes its own fetchStatus over them, so the argument is discarded for every value, not only 'paused'.
QueryCache.findAll honours the same filter correctly, which makes the difference easy to miss — the filter works through one entry point and is silently dropped through the other.
Minimal reproduction
import { QueryClient } from '@tanstack/query-core'
const client = new QueryClient()
const queryKey = ['session']
const cache = client.getQueryCache()
const query = cache.build(client, { queryKey, queryFn: async () => 'x' })
query.setState({ fetchStatus: 'paused' })
console.log(cache.find({ queryKey })?.state.fetchStatus) // 'paused'
console.log(cache.findAll({ queryKey, fetchStatus: 'paused' }).length) // 1
console.log(client.isFetching({ queryKey, fetchStatus: 'paused' })) // 0
console.log(client.isFetching({ queryKey, fetchStatus: 'idle' })) // 0
Expected / actual
| call | expected | actual |
|---|---|---|
findAll({ fetchStatus: 'paused' }).length |
1 | 1 |
isFetching({ fetchStatus: 'paused' }) |
1, or a type error | 0 |
isFetching({ fetchStatus: 'idle' }) |
1, or a type error | 0 |
Either outcome would be fine. What is awkward is a public, typed, documented parameter that is accepted and does nothing.
Cause
packages/query-core/src/queryClient.ts:
isFetching(filters) {
return this.#queryCache.findAll({ ...filters, fetchStatus: 'fetching' }).length
}
useIsFetching forwards its filters to this method, so it behaves the same way.
Why it came up
An app that asks "is this query still waiting on the network" wants paused to count: a lookup held because the browser is offline, or because the window is unfocused and the retry is deferred, has not answered yet. Reading it through useIsFetching({ queryKey, fetchStatus: 'paused' }) compiles and quietly answers 0, so the UI treats a waiting query as a settled one. In our case a page showed a "not found" state to someone whose session lookup was merely paused.
The workaround is to subscribe to the cache and use findAll directly, which works but means reimplementing what useIsFetching exists to provide.
Possible resolutions
In rough order of how little they change:
- Type it out — omit
fetchStatusfrom the filters these two accept, so passing it is a compile error, and say in the reference that they count fetching queries only. - Honour it — use the caller's
fetchStatuswhen one is given and default to'fetching'otherwise. This changes behaviour for anyone currently passing a value and relying on it being ignored, which seems unlikely but is a real semver consideration. - Leave the behaviour and document it — note on
useIsFetchingandQueryClient.isFetchingthatfetchStatusis fixed, and point atgetQueryCache().findAllfor other statuses.
Happy to send a PR for whichever you prefer.
Related
- Discussion #6756 proposes a built-in
queryClient.isPaused/useIsPaused, and its example hook uses the same spread-then-override pattern in user code. If that proposal is the intended answer, this is the part of it that bites today — and option 1 or 3 above would stop the current API misleading people in the meantime. - #7559 and #8531 are about
isFetchingreporting the wrong thing for fetching queries; this is narrower, about a filter argument being inert.
Environment
@tanstack/query-core5.104.1- Node 26.11.1, TypeScript 6.0.3
- Reproduced with
query-corealone, so no framework adapter is involved
- Langage dominant
- TypeScript
- Étoiles
- 50.4k
- Forks
- 4.3k
- Merge moyen
- 12 h 18 min
- PR mergées (30 j)
- 488
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Peut-être à nouveau libre @LeonxLJX l’a pris il y a 45 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
TanStack/query#11358 · 2 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingPeut-être pris @UzumakiODZ l’a pris il y a 4 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 28/100
TanStack/query#12031 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryPeut-être pris @AdzerKI l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
TanStack/query#12025 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
restoreQueries and persisterGc throw on malformed persisted entriesPeut-être pris @VGontier-cmd l’a pris il y a 13 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
TanStack/query#11903 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/query
Issues similaires
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Koenkk/zigbee-herdsman-converters#13540 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: Tequila Music TV RO SDOuvertecheck:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
iptv-org/iptv#55821 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
area/busola/ux
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
kyma-project/busola#5442 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
vercel-labs/wterm#246 ·
Les mainteneurs répondent en général sous 1 jour