Skip to content

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Jan 31, 2026

🎯 Changes

Remove the unreachable willFetch branch in useQueries suspense promise collection.

In v4, useQueries allowed individual queries to set suspense: true/false, so a mix of suspense and non-suspense queries was possible. The willFetch branch handled prefetching for non-suspense queries within a suspense batch.

In v5, suspense was omitted from UseQueryOptions and useSuspenseQueries applies suspense: true to all queries uniformly. This makes the mixed suspense/non-suspense scenario unreachable through the public API, leaving the willFetch branch as dead code.

This PR removes:

  • The willFetch branch (else if (willFetch(result, isRestoring)))
  • The unused willFetch import from ./suspense

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 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

  • Refactor
    • Optimized internal query fetching logic for improved efficiency and maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2026

⚠️ No Changeset found

Latest commit: 6c4763d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

Removed the willFetch import and simplified the suspense preparation logic in useQueries by collapsing a nested conditional into a single combined condition, eliminating the secondary invocation path.

Changes

Cohort / File(s) Summary
Suspense Logic Simplification
packages/react-query/src/useQueries.ts
Removed willFetch import and refactored the conditional logic from a nested if-else structure to a combined condition (if (opts && shouldSuspend(opts, result))), eliminating the secondary path that previously triggered fetchOptimistic through willFetch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • TkDodo
  • manudeli

Poem

🐰 A hook grows sleek when branches fall,
Two paths collapse to one—that's all!
The willFetch fades like morning dew,
While shouldSuspend brings clarity through.
Simpler logic, cleaner way,
A rabbit cheers the code today! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: removing an unreachable 'willFetch' branch from suspense promise collection in useQueries.
Description check ✅ Passed The PR description comprehensively covers all required sections: detailed explanation of changes, clear motivation/context, completed checklist items, and proper release impact assessment.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 31, 2026

View your CI Pipeline Execution ↗ for commit 6c4763d

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

☁️ Nx Cloud last updated this comment at 2026-01-31 04:56:52 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 31, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 6c4763d

@sukvvon sukvvon marked this pull request as ready for review January 31, 2026 05:01
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.

1 participant