Repository navigation
fix(query-core): skip pausing cancelled retries - #11537
Conversation
Check whether the retryer settled before its delayed continuation can notify a pause. A cancelled retry must not overwrite a replacement fetch status or prevent an inactive query from being collected. Cover offline and unfocused retries, replacement fetches, garbage collection, and React cancellation with and without Strict Mode.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Retry delay resolution guard packages/query-core/src/retryer.ts, .changeset/cancelled-retry-pause.md |
The retryer checks whether it has resolved before pausing after a retry delay. The changeset declares a patch release for @tanstack/query-core. |
Cancellation behavior coverage packages/query-core/src/__tests__/retryer.test.tsx, packages/query-core/src/__tests__/query.test.tsx, packages/react-query/src/__tests__/useQuery.test.tsx |
Tests cover cancelled retryers, replacement fetches, garbage collection, and fetch status while focus changes. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: sukvvon, tkdodo
Merge Risk: 
Minimal · up to f6729
-
Cancelled retries no longer leave queries paused after settlement. No merge-blocking issue was identified.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description includes the required Changes, Checklist, and Release Impact sections. It explains the bug, fix, regression coverage, validation results, and changeset. It also transparently records that the full test:pr run was not performed and that the AI contribution checklist item remains unchecked.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files.
-
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.
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified.
Pull request overview
Fixes cancelled retry continuations incorrectly pausing settled queries, with core and React regression coverage.
Changes:
- Skip pause notifications after retryer settlement.
- Add cancellation, replacement-fetch, garbage-collection, and Strict Mode tests.
- Add a query-core patch changeset.
File summaries
| File | Description |
|---|---|
packages/react-query/src/__tests__/useQuery.test.tsx |
Tests React cancellation behavior with and without Strict Mode. |
packages/query-core/src/retryer.ts |
Prevents settled retryers from pausing queries. |
packages/query-core/src/__tests__/retryer.test.tsx |
Tests cancelled retry behavior. |
packages/query-core/src/__tests__/query.test.tsx |
Tests replacement fetches and garbage collection. |
.changeset/cancelled-retry-pause.md |
Documents the patch release. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…-pause # Conflicts: # packages/query-core/src/retryer.ts
🦋 Changeset detectedLatest commit: f67292a The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
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 |
|
Could someone help me replace this PR from the rewritten branch? I rewrote the commits on my personal fork so the author and committer use my personal GitHub identity. The patch is unchanged, but this PR still shows the old head ( |
|
View your CI Pipeline Execution ↗ for commit f67292a
☁️ Nx Cloud last updated this comment at |
🎯 Changes
A retry delay can expire after
cancelQuerieshas already settled the fetch. If the client is offline or unfocused, that old continuation still callsonPause, changing the cancelled query from idle to paused. It can also overwrite a replacement fetch's status and prevent an inactive query from being garbage-collected.Skip pausing once the retryer has settled. Adds deterministic fake-timer regressions for offline/unfocused cancellation, replacement-fetch status, garbage collection, and React with and without Strict Mode.
Reproduced on 5.101.2, stable 5.103.1 source, and main (
bb9d313). All six new core/React regression cases failed before the fix. Afterward, 1,601 core assertions and 585 React tests pass. Searches found no matching active fix; #10291 handles initially paused fetches on unmount and #11342 handles silent-cancellation promise results, rather than delayed pause notifications.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.The full cross-framework
test:prrun was not performed. Both affected packages passedtest:lib,test:types,test:eslint, andtest:buildthrough Nx, including dependency builds. The compiler matrix covers TypeScript 5.6, 5.7, 5.8, 5.9, 6.0, and 7.0. Existing lint warnings are in unchanged code. Tested on Node 24.13.0.Implemented and locally verified with AI assistance. The contributor-understanding checkbox is left for the author's review.
🚀 Release Impact
Summary by CodeRabbit