fix(query-core): skip pausing cancelled retries - #11537
brennanbutler01 wants to merge 1 commit into
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. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe retryer now skips pausing when cancellation resolves during a retry delay. Query-core and React Query tests cover replacement fetches, garbage collection, retryer callbacks, and fetch status. ChangesCancelled retry handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The cancellation retry-delay fix is covered across core and React scenarios and is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
🎯 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
Bug Fixes
Tests