Skip to content

ref: switch to use() - #11237

Merged
TkDodo merged 13 commits into
query-v6from
tkdodo/ref/use-over-throw
Nov 21, 2026
Merged

TkDodo merged 13 commits into
query-v6from
tkdodo/ref/use-over-throw

Conversation

@TkDodo

@TkDodo TkDodo commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved Suspense behavior across queries, including promise reuse, parallel loading, fallback handling, and error recovery.
    • Improved support for transitioned queries, cached or stale data, and skip-token scenarios.
    • Enhanced compatibility across React versions when handling Suspense-enabled queries.
    • Improved consistency when rendering Suspense content asynchronously.
  • Tests

    • Expanded coverage for Suspense queries, infinite queries, prefetching, retries, and error boundaries.
    • Improved validation of asynchronous rendering, loading states, fallback behavior, and cached promise reuse.

@nx-cloud

nx-cloud Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit c05305c

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

☁️ Nx Cloud last updated this comment at 2026-11-21 17:07:18 UTC

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Walkthrough

React Query now caches suspense promises, consumes them through React’s use, and starts multiple suspense queries before suspension. Tests use an asynchronous suspense renderer and asynchronous act for retries and query updates.

Changes: Suspense integration

Layer / File(s) Summary
Suspense promise handling and query hook flow
packages/react-query/src/suspense.ts, packages/react-query/src/useBaseQuery.ts, packages/react-query/src/useQueries.ts
Added React-compatible thenable handling and per-query promise caching. Query hooks now consume suspense promises with use(), and useQueries starts all suspense fetches before suspension.
Suspense test renderer and query suites
packages/react-query/src/__tests__/utils.tsx, packages/react-query/src/__tests__/suspense.test.tsx, packages/react-query/src/__tests__/useSuspenseQuery.test.tsx, packages/react-query/src/__tests__/useSuspenseQueries.test.tsx, packages/react-query/src/__tests__/useSuspenseInfiniteQuery.test.tsx
Renamed and expanded the suspense renderer. Tests now use configurable fallbacks, await suspense rendering, and wrap asynchronous interactions in act.
Prefetch and error-boundary test updates
packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx, packages/react-query/src/__tests__/usePrefetchQuery.test.tsx, packages/react-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
Updated suspense rendering helpers and asynchronous retry interactions while preserving existing assertions.
Release metadata
.changeset/tasty-ears-study.md
Added a patch Changeset for the suspense implementation change.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QueryHook
  participant SuspenseUtilities
  participant React
  QueryHook->>SuspenseUtilities: request suspense promise
  SuspenseUtilities-->>QueryHook: return cached or new promise
  QueryHook->>React: call use with thenable
  React-->>QueryHook: suspend until settlement
  React-->>QueryHook: render data or throw error
Loading
Merge Risk: Minimal · up to 8a855

This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description, so it does not provide the required changes, checklist, or release impact information. Add the required Changes, Checklist, and Release Impact sections, and complete the applicable checklist items.
Docstring Coverage ⚠️ Warning 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 32 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)

Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: switching React suspense handling to use().
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Commit unit tests in branch tkdodo/ref/use-over-throw
  • 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.

Share

ℹ️ Recent review info

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63ebf11a-07a8-46a6-96db-5027f0ba6fe5

📥 Commits

Reviewing files that changed from the base of the PR and between 106f3c3 and 8a8555a.

📒 Files selected for processing (1)

  • packages/react-query/src/__tests__/transition.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 24 bumped as dependents.

🟥 Major bumps

Package Version Reason
@tanstack/query-core 5.108.2 → 6.0.0 Changeset
@tanstack/react-query 5.108.2 → 6.0.0 Changeset
@tanstack/angular-query 5.108.2 → 6.0.0 Dependent
@tanstack/angular-query-devtools 5.108.2 → 6.0.0 Dependent
@tanstack/angular-query-persist-client 5.108.2 → 6.0.0 Dependent
@tanstack/eslint-plugin-query 5.108.2 → 6.0.0 Dependent
@tanstack/preact-query 5.108.2 → 6.0.0 Dependent
@tanstack/preact-query-devtools 5.108.2 → 6.0.0 Dependent
@tanstack/preact-query-persist-client 5.108.2 → 6.0.0 Dependent
@tanstack/query-async-storage-persister 5.108.2 → 6.0.0 Dependent
@tanstack/query-broadcast-client-experimental 5.108.2 → 6.0.0 Dependent
@tanstack/query-devtools 5.108.2 → 6.0.0 Dependent
@tanstack/query-persist-client-core 5.108.2 → 6.0.0 Dependent
@tanstack/query-sync-storage-persister 5.108.2 → 6.0.0 Dependent
@tanstack/react-query-devtools 5.108.2 → 6.0.0 Dependent
@tanstack/react-query-next-experimental 5.108.2 → 6.0.0 Dependent
@tanstack/react-query-persist-client 5.108.2 → 6.0.0 Dependent
@tanstack/solid-query 5.108.2 → 6.0.0 Dependent
@tanstack/solid-query-devtools 5.108.2 → 6.0.0 Dependent
@tanstack/solid-query-persist-client 5.108.2 → 6.0.0 Dependent
@tanstack/vue-query 5.108.2 → 6.0.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.42 → 0.2.43 Dependent
@tanstack/svelte-query 6.4.5 → 6.4.6 Dependent
@tanstack/svelte-query-devtools 6.4.5 → 6.4.6 Dependent
@tanstack/svelte-query-persist-client 6.4.5 → 6.4.6 Dependent
@tanstack/vue-query-devtools 6.4.5 → 6.4.6 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query

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

@tanstack/angular-query-devtools

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

@tanstack/angular-query-persist-client

npm i https://pkg.pr.new/@tanstack/angular-query-persist-client@11237

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11237

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11237

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11237

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: c05305c

@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.03 KB (+1.17% 🔺)
react minimal 8.83 KB (+1.81% 🔺)

@manuelj555

This comment was marked as resolved.

@manuelj555

This comment was marked as resolved.

@TkDodo

TkDodo commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Yeah this has nothing todo with use(). We shipped a new version yesterday with queryClient.query(), which usePrefetchQuery uses internally. Maybe the sandbox has a wrong version of query-core cached

@TkDodo
TkDodo changed the base branch from main to query-v6 November 21, 2026 17:01
@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c05305c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@tanstack/react-query Major
@tanstack/react-query-devtools Major
@tanstack/react-query-next-experimental Major
@tanstack/react-query-persist-client Major
@tanstack/angular-query-devtools Major
@tanstack/angular-query-persist-client Major
@tanstack/angular-query Major
@tanstack/eslint-plugin-query Major
@tanstack/preact-query-devtools Major
@tanstack/preact-query-persist-client Major
@tanstack/preact-query Major
@tanstack/query-async-storage-persister Major
@tanstack/query-broadcast-client-experimental Major
@tanstack/query-core Major
@tanstack/query-devtools Major
@tanstack/query-persist-client-core Major
@tanstack/query-sync-storage-persister Major
@tanstack/solid-query-devtools Major
@tanstack/solid-query-persist-client Major
@tanstack/solid-query Major
@tanstack/vue-query Major
@tanstack/lit-query Patch
@tanstack/svelte-query Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools Patch
@tanstack/svelte-query-persist-client Patch

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

@TkDodo
TkDodo merged commit 19e322e into query-v6 Nov 21, 2026
9 checks passed
@TkDodo
TkDodo deleted the tkdodo/ref/use-over-throw branch November 21, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants