From a5ef57f18b33889d0f4984878716cfdbe1fe9a3f Mon Sep 17 00:00:00 2001 From: seongwon seo Date: Mon, 18 May 2026 19:04:03 +0900 Subject: [PATCH 1/3] docs(reference/QueryCache): clarify fetchFailureCount availability in onError callback --- docs/reference/QueryCache.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/reference/QueryCache.md b/docs/reference/QueryCache.md index 09a9c8e5357..ebe852a04bc 100644 --- a/docs/reference/QueryCache.md +++ b/docs/reference/QueryCache.md @@ -11,8 +11,13 @@ The `QueryCache` is the storage mechanism for TanStack Query. It stores all the import { QueryCache } from '@tanstack/react-query' const queryCache = new QueryCache({ - onError: (error) => { - console.log(error) + onError: (error, query) => { + // query.state.fetchFailureCount reflects total attempts (initial + retries) + if (query.state.fetchFailureCount > 1) { + console.error(`Failed after retries:`, error) + } else { + console.error(`First attempt failed:`, error) + } }, onSuccess: (data) => { console.log(data) @@ -38,6 +43,7 @@ Its available methods are: - `onError?: (error: unknown, query: Query) => void` - Optional - This function will be called if some query encounters an error. + - `query.state.fetchFailureCount` indicates how many attempts were made (including retries), which can be used to differentiate a first failure from a failure after retries. - `onSuccess?: (data: unknown, query: Query) => void` - Optional - This function will be called if some query is successful. From 386afab4ffb3312bad61e704a51e1bc641961828 Mon Sep 17 00:00:00 2001 From: seongwon seo Date: Wed, 20 May 2026 10:54:37 +0900 Subject: [PATCH 2/3] docs(reference/QueryCache): improve fetchFailureCount comment clarity --- docs/reference/QueryCache.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/QueryCache.md b/docs/reference/QueryCache.md index ebe852a04bc..8f24b5a43ed 100644 --- a/docs/reference/QueryCache.md +++ b/docs/reference/QueryCache.md @@ -12,7 +12,7 @@ import { QueryCache } from '@tanstack/react-query' const queryCache = new QueryCache({ onError: (error, query) => { - // query.state.fetchFailureCount reflects total attempts (initial + retries) + // query.state.fetchFailureCount is the total number of failed attempts including retries if (query.state.fetchFailureCount > 1) { console.error(`Failed after retries:`, error) } else { From ff5805be2cae222cf62fd83d4ebacde7ddea2f5a Mon Sep 17 00:00:00 2001 From: seongwon seo Date: Wed, 20 May 2026 12:02:27 +0900 Subject: [PATCH 3/3] docs(reference/QueryCache): clarify fetchFailureCount counts failed attempts --- docs/reference/QueryCache.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/QueryCache.md b/docs/reference/QueryCache.md index 8f24b5a43ed..5740021ac79 100644 --- a/docs/reference/QueryCache.md +++ b/docs/reference/QueryCache.md @@ -43,7 +43,7 @@ Its available methods are: - `onError?: (error: unknown, query: Query) => void` - Optional - This function will be called if some query encounters an error. - - `query.state.fetchFailureCount` indicates how many attempts were made (including retries), which can be used to differentiate a first failure from a failure after retries. + - `query.state.fetchFailureCount` indicates how many failed fetch attempts were made (including retries), which can be used to differentiate a first failure from a failure after retries. - `onSuccess?: (data: unknown, query: Query) => void` - Optional - This function will be called if some query is successful.