fix(query-core): reset infinite-query signal consumption - #11532
brennanbutler01 wants to merge 1 commit into
Conversation
Reset signal consumption before query behavior replaces the fetch function. Earlier signal consumption must not cancel a later fetch that never reads its signal when the last observer unmounts. Cover refetching, next-page fetching, and React unmounts 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 (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthrough
ChangesInfinite query signal reset
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change addresses the stale signal-consumption state and includes targeted coverage for the affected caching behavior. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
The fix is covered by core and React regressions with no unresolved blocking issues.
Pull request overview
Fixes stale abort-signal consumption in subsequent infinite-query fetches.
Changes:
- Reset signal consumption for each fetch.
- Add core and React regression tests.
- Add a patch changeset.
File summaries
| File | Description |
|---|---|
packages/react-query/src/__tests__/useInfiniteQuery.test.tsx |
Tests unmount behavior with and without Strict Mode. |
packages/query-core/src/query.ts |
Resets abort-signal state per fetch. |
packages/query-core/src/__tests__/infiniteQueryBehavior.test.tsx |
Covers refetch and next-page regressions. |
.changeset/fix-infinite-query-signal-reset.md |
Documents the patch release. |
Review details
- Files reviewed: 4/4 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
After an infinite-query fetch reads
context.signal, a later fetch that never reads the signal can still be cancelled when its last observer unmounts. Its result is discarded instead of reaching the cache. The equivalent ordinary query caches the result correctly.Reset signal consumption when creating each fetch's AbortController. The existing reset inside the ordinary fetch function remains; infinite-query behavior replaces that function and previously skipped the reset entirely.
Adds core regressions for refetching and fetching the next page, plus React unmount coverage with and without Strict Mode. Both new core regressions failed before the fix; all core and React tests now pass. A standalone public-API reproduction also passes against the built package.
Reproduced on 5.101.2, the 5.103.1 release source, and
66d4fe3. Related to the skipped reset discussed in #3492; this reproduction concerns a later fetch after a successful initial fetch, rather than duplicate initial requests in Strict Mode.✅ 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