fix(query-core): do not schedule garbage collection on the server #12026
main fromrefs/pull/12026/head·opened View on GitHub🎯 Changes#
On the server, scheduleGc now returns early, so no timer is scheduled even when gcTime is set explicitly (the gcTime value itself is still kept). Added a test and a patch changeset for @tanstack/query-core.
Fixes #12025
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 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#
- Bug Fixes
- Garbage collection is no longer scheduled on the server, even when an explicit garbage-collection time is set. Client-side garbage collection continues to work as before.
- 1
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: TanStack/query/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
740f748c-f44b-4ef3-94fa-cafa92cba966
📥 Commits
-
Reviewing files that changed from the base of the PR and between a8af0e243af6f09d670ea2ec9849c4e3e3bc17ed and 56cc6ee79d48f0c6fc04ef060082a499773a6ba0.
📒 Files selected for processing: 3
-
.changeset/quiet-timers-rest.mdpackages/query-core/src/__tests__/query.test.tsxpackages/query-core/src/removable.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
Server-side query garbage collection no longer schedules a timeout when
gcTimeis explicitly set. A test verifies that the configured value remains set and that no timeout is scheduled.Changes: Server-side garbage collection
Layer / File(s) Summary Prevent server-side GC timers
packages/query-core/src/removable.ts,packages/query-core/src/__tests__/query.test.tsx,.changeset/quiet-timers-rest.mdscheduleGcnow returns without scheduling a timeout on the server. The test checks this behavior withgcTime: 1000. The changeset records the patch.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
sukvvon
Merge Risk: ⚪ Minimal · up to
56cc6-
Server-side queries retain their configured gcTime without scheduling GC timers, and the supplied test covers the explicit-value case. No actionable merge risk is evident.
Pre-merge checks:
5-
Passed checks: 5 passed-
Check name Status Explanation Title check The title clearly and concisely describes the main change: preventing garbage-collection scheduling on the server in query-core. Description check The description covers the change and motivation, references the linked issue, completes the required checklist, and records the release impact with a changeset. Linked Issues check Issue [ #12025] requires no garbage-collection timer on the server for anygcTimevalue while retaining the value.Removable.scheduleGc()now clears an existing timeout and returns when `isServerEn…Out of Scope Changes check The changed implementation directly addresses server-side garbage-collection scheduling. The test covers the explicit gcTimecase from issue [#12025]. The changeset documents the published `@tanstac…Docstring Coverage No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
-
✨ 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.
Comment `@coderabbitai help` to get the list of available commands.-
TkDodo closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 56cc6ee79d48f0c6fc04ef060082a499773a6ba0
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