Skip to content

Comments

feat(solid-query/useQueries): add Suspense support#10170

Draft
sukvvon wants to merge 7 commits intoTanStack:mainfrom
sukvvon:feat/solid-query-useQueries-suspense
Draft

feat(solid-query/useQueries): add Suspense support#10170
sukvvon wants to merge 7 commits intoTanStack:mainfrom
sukvvon:feat/solid-query-useQueries-suspense

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 22, 2026

🎯 Changes

Add Suspense support to useQueries by following the same createResource pattern used in useBaseQuery.

Implementation

  • Single createResource with resolver pattern for suspend/resolve/reject
  • needsSuspend() helper to check if any query is fetching and loading
  • Proxy handler on data property to trigger Suspense lazily when accessed
  • Error handling with shouldThrowError for Error Boundary integration
  • Offline (paused) state handling to prevent unnecessary Suspense fallback
  • Resolver cleanup on unmount to prevent Suspense hanging
  • Task queue with queueMicrotask for batched state updates

Tests (23 cases)

Test scenarios are based on react-query's useSuspenseQueries tests, adapted for Solid's reactivity model.

  • Suspend on mount / resolve queries
  • Not suspend when cached data exists
  • Suspend when switching query keys
  • Not suspend when queries are disabled
  • Suspend all queries in parallel
  • Only call combine after resolving
  • Handle duplicate query keys without infinite loops
  • Not break suspense when queries change without resolving
  • Suspend only once per queries change
  • Not unmount before all promises fetched
  • Throw error when queryKey changes and new query fails
  • Show error boundary even with gcTime:0
  • GC when unmounted while fetching with low gcTime
  • Suspend on offline when query changes
  • Still suspend if queryClient has placeholderData config
  • Not call queryFn twice in Suspense mode
  • Remove query instance when component unmounted
  • Suspend only pending queries when some already have cached data
  • Suspend when queries count increases dynamically
  • Suspend with select option
  • Not suspend disabled queries while enabled queries suspend
  • Not re-suspend when invalidating queries with existing data
  • Not suspend when all queries have staleTime: Infinity and cached data

✅ 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).

@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2026

🦋 Changeset detected

Latest commit: 8b25dc6

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

This PR includes changesets to release 3 packages
Name Type
@tanstack/solid-query Minor
@tanstack/solid-query-devtools Major
@tanstack/solid-query-persist-client Major

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

Important

Review skipped

Draft detected.

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.

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
✨ Finishing Touches
🧪 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 Feb 22, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 8b25dc6

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

☁️ Nx Cloud last updated this comment at 2026-02-22 17:43:09 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 22, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 8b25dc6

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