Skip to content

Conversation

m2na7
Copy link
Contributor

@m2na7 m2na7 commented Sep 1, 2025

Summary

  • Replace hardcoded 1000ms values with MIN_SUSPENSE_TIME_MS constant in suspense timer logic
  • Improves code readability and maintainability by eliminating magic numbers

Summary by CodeRabbit

  • Bug Fixes
    • Standardizes minimum Suspense timing to 1s, providing more predictable loading fallback behavior.
    • Aligns cache cleanup minimums in Suspense mode for consistent timing across queries.
    • No changes to the public API.

Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Introduces a local MIN_SUSPENSE_TIME_MS constant (1000 ms) in ensureSuspenseTimers and replaces hard-coded 1000 usages. Applies the minimum to clamp logic for suspense timing and to defaultedOptions.gcTime. Behavior for function-based staleTime remains wrapped with clamp. No public API signatures changed.

Changes

Cohort / File(s) Summary
Suspense timing minimum consolidation
packages/react-query/src/suspense.ts
Added MIN_SUSPENSE_TIME_MS constant; replaced hard-coded 1000 in clamp and defaultedOptions.gcTime; ensured universal minimum suspense timing; preserved function staleTime handling; no exported API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers, count to one—
A thousand ticks, then hop, I’m done.
Timers clamped, no sudden leap,
Suspense now holds a steadier keep.
In burrows deep, I test and wait—
Then bound ahead at a measured rate. 🐇⏱️

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/react-query/src/suspense.ts (1)

27-27: Nice extraction; consider module-level const and de-hardcode the comment.

  • Moving MIN_SUSPENSE_TIME_MS to module scope avoids redeclaration on every call and makes reuse trivial if more sites need the same minimum.
  • The preceding comment still hardcodes “1000ms”. Prefer wording that references the constant (e.g., “minimum suspense time”) to prevent drift if the value changes.

Apply within this hunk:

-    const MIN_SUSPENSE_TIME_MS = 1000
+    // Use module-level MIN_SUSPENSE_TIME_MS (see top of file)

Add outside this hunk (top-level, after imports):

// Minimum suspense-related time window to avoid thrashing on remounts
const MIN_SUSPENSE_TIME_MS = 1000
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0650eaf and adc481c.

📒 Files selected for processing (1)
  • packages/react-query/src/suspense.ts (2 hunks)
🔇 Additional comments (3)
packages/react-query/src/suspense.ts (3)

29-31: Clamp logic reads well and preserves previous semantics.

Keeps the 'static' sentinel intact and enforces the minimum for numeric/undefined values. Looks good.


38-40: Consistent minimum for gcTime in Suspense.

Aligns gcTime with the same minimum; Infinity remains unaffected. LGTM.


21-42: No additional magic 1000ms literals in source—only in tests verifying behavior; no further changes needed.

Copy link

nx-cloud bot commented Sep 2, 2025

View your CI Pipeline Execution ↗ for commit adc481c

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

☁️ Nx Cloud last updated this comment at 2025-09-02 07:56:10 UTC

@TkDodo TkDodo merged commit ef0c16e into TanStack:main Sep 2, 2025
4 of 5 checks passed
Copy link

pkg-pr-new bot commented Sep 2, 2025

More templates

@tanstack/angular-query-devtools-experimental

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

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: adc481c

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.42%. Comparing base (a1b1279) to head (adc481c).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9607       +/-   ##
===========================================
+ Coverage   45.15%   84.42%   +39.27%     
===========================================
  Files         208       26      -182     
  Lines        8323      366     -7957     
  Branches     1886      107     -1779     
===========================================
- Hits         3758      309     -3449     
+ Misses       4118       48     -4070     
+ Partials      447        9      -438     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental ∅ <ø> (∅)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools ∅ <ø> (∅)
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query 95.97% <100.00%> (+0.01%) ⬆️
@tanstack/react-query-devtools 10.00% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query ∅ <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client ∅ <ø> (∅)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants