Skip to content

feat(@suspensive/react-query-5): add shouldDehydratePromise to QueriesHydration#1947

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/feature-queries-hydration-dehydrate-promise
Draft

feat(@suspensive/react-query-5): add shouldDehydratePromise to QueriesHydration#1947
Copilot wants to merge 3 commits intomainfrom
copilot/feature-queries-hydration-dehydrate-promise

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

QueriesHydration always awaited all queries before dehydrating, so pending promises were never included in the dehydrated state — blocking streaming SSR patterns in RSC.

Changes

  • New shouldDehydratePromise prop (boolean, default false): when true, queries are fired without await and dehydrate is called with a custom shouldDehydrateQuery that includes pending-status queries alongside the default success ones. TanStack Query v5's dehydrateQuery already attaches the live promise for pending queries; this change ensures the filter doesn't discard them.
  • Unhandled rejection guard: each started promise gets a .catch(() => {}) — errors are already tracked inside the QueryClient cache, so this purely prevents Node from surfacing an unhandled rejection warning.
  • timeout / skipSsrOnError are bypassed when shouldDehydratePromise is true — the component returns the HydrationBoundary immediately.
// Streaming SSR — client subscribes to in-flight promises via HydrationBoundary
<QueriesHydration
  queries={[userQueryOptions(userId), postsQueryOptions()]}
  shouldDehydratePromise
>
  <UserProfile />
</QueriesHydration>

On the client, HydrationBoundary receives a dehydrated state that includes pending queries with their promises, and TanStack Query calls query.fetch({ initialPromise }) to subscribe to the streamed result.

Only applies to @suspensive/react-query-5 — v4 has no promise dehydration support.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

⚠️ No Changeset found

Latest commit: 03880f9

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

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
suspensive-next-streaming-react-query Ready Ready Preview, Comment Apr 4, 2026 1:32am
v2.suspensive.org Ready Ready Preview, Comment Apr 4, 2026 1:32am
v3.suspensive.org Ready Ready Preview, Comment Apr 4, 2026 1:32am
visualization.suspensive.org Ready Ready Preview, Comment Apr 4, 2026 1:32am

Request Review

@manudeli
Copy link
Copy Markdown
Member

manudeli commented Apr 4, 2026

@copilot If user use shouldDehydratePromise, we should prevent use case for unnecessary prop with shouldDehydratePromise. so we need to use function overloads

@coauthors
Copy link
Copy Markdown

coauthors bot commented Apr 4, 2026

People can be co-author:

Candidate Reasons Count Add this as commit message
@Copilot #1947 1 Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
@manudeli #1947 (comment) 1 Co-authored-by: manudeli <61593290+manudeli@users.noreply.github.com>

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot If user use shouldDehydratePromise, we should prevent use case for unnecessary prop with shouldDehydratePromise. so we need to use function overloads

Done in 03880f9. QueriesHydration now uses two overload signatures:

  1. shouldDehydratePromise: true → only the base props (queries, queryClient, children, plus passthrough HydrationBoundaryProps); skipSsrOnError and timeout are absent from the type
  2. shouldDehydratePromise?: false → full props including skipSsrOnError and timeout

Passing skipSsrOnError or timeout alongside shouldDehydratePromise: true is now a compile-time type error, verified with @ts-expect-error assertions in the type-test file.

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.

[Feature]: QueriesHydration shouldDehydarte promise

2 participants