Skip to content

docs(reference/QueryCache): clarify fetchFailureCount availability in onError callback#10724

Open
seongwon030 wants to merge 3 commits into
TanStack:mainfrom
seongwon030:seoseongwon-docs/querycache-onerror-fetchfailurecount
Open

docs(reference/QueryCache): clarify fetchFailureCount availability in onError callback#10724
seongwon030 wants to merge 3 commits into
TanStack:mainfrom
seongwon030:seoseongwon-docs/querycache-onerror-fetchfailurecount

Conversation

@seongwon030
Copy link
Copy Markdown

@seongwon030 seongwon030 commented May 18, 2026

🎯 Changes

The query parameter passed to QueryCache's onError callback already exposes
query.state.fetchFailureCount, which reflects the total number of failed attempts
(initial + retries). However, this was not documented, leading users to believe retry
attempt count was inaccessible in error callbacks (see #10713).

  • Updated code example to show query parameter usage with a practical retry-count check
  • Added a note to the onError option description about fetchFailureCount

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 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

  • Documentation
    • Clarified that the onError handler receives both the error and the related query object as parameters.
    • Added guidance showing how to use fetchFailureCount (which includes retries) to distinguish first-time failures from failures after retry attempts.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 571393c5-b5b9-48ff-a351-89b354ba9db5

📥 Commits

Reviewing files that changed from the base of the PR and between 386afab and ff5805b.

📒 Files selected for processing (1)
  • docs/reference/QueryCache.md
✅ Files skipped from review due to trivial changes (1)
  • docs/reference/QueryCache.md

📝 Walkthrough

Walkthrough

Updated QueryCache docs: the onError handler example now receives (error, query) and uses query.state.fetchFailureCount to log differently for initial failures versus failures after retries. A doc note clarifies that fetchFailureCount includes retries.

Changes

QueryCache onError Handler Documentation

Layer / File(s) Summary
onError handler example and fetchFailureCount clarification
docs/reference/QueryCache.md
The onError handler example is updated to accept (error, query) parameters and branch logging logic based on query.state.fetchFailureCount to distinguish initial failures from post-retry failures. Documentation adds a note that fetchFailureCount includes retries.

Estimated Code Review Effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I'm a rabbit in the docs tonight,
Tuning errors until they're right,
Count the fetches, spot retries,
First-fail logs and clearer eyes,
Hopping off — the docs feel light! 🐰📖

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: documenting fetchFailureCount availability in the onError callback for QueryCache.
Description check ✅ Passed The description covers all required sections: changes with motivation, completed checklist items, and correct release impact classification for documentation-only changes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 18, 2026

View your CI Pipeline Execution ↗ for commit a5ef57f

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

☁️ Nx Cloud last updated this comment at 2026-05-18 18:08:11 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: a5ef57f

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/reference/QueryCache.md (1)

46-46: ⚡ Quick win

Improve clarity: specify "failed attempts" rather than "attempts".

The phrase "how many attempts were made" could be slightly ambiguous. Consider clarifying that it specifically counts failed attempts.

📝 Suggested wording improvement
-  - `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 attempts were made (including retries), which can be used to differentiate a first failure from a failure after retries.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reference/QueryCache.md` at line 46, The sentence about
query.state.fetchFailureCount is ambiguous—update the wording to say it counts
failed attempts rather than generic attempts; specifically change the line
containing `query.state.fetchFailureCount` to read something like
"`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." Ensure the phrase "failed attempts" replaces
"attempts" and keep the rest of the explanation intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/reference/QueryCache.md`:
- Line 46: The sentence about query.state.fetchFailureCount is ambiguous—update
the wording to say it counts failed attempts rather than generic attempts;
specifically change the line containing `query.state.fetchFailureCount` to read
something like "`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." Ensure the phrase "failed attempts"
replaces "attempts" and keep the rest of the explanation intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f076a59f-b330-4a25-9c6a-2f562900023a

📥 Commits

Reviewing files that changed from the base of the PR and between a5ef57f and 386afab.

📒 Files selected for processing (1)
  • docs/reference/QueryCache.md

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