You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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<QueriesHydrationqueries={[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.
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
CopilotAI
changed the title
[WIP] Add support to dehydrate pending promise in QueriesHydration
feat(@suspensive/react-query-5): add shouldDehydratePromise to QueriesHydrationApr 3, 2026
@copilot If user use shouldDehydratePromise, we should prevent use case for unnecessary prop with shouldDehydratePromise. so we need to use function overloads
@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:
shouldDehydratePromise: true → only the base props (queries, queryClient, children, plus passthrough HydrationBoundaryProps); skipSsrOnError and timeout are absent from the type
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
QueriesHydrationalways awaited all queries before dehydrating, so pending promises were never included in the dehydrated state — blocking streaming SSR patterns in RSC.Changes
shouldDehydratePromiseprop (boolean, defaultfalse): whentrue, queries are fired withoutawaitanddehydrateis called with a customshouldDehydrateQuerythat includespending-status queries alongside the defaultsuccessones. TanStack Query v5'sdehydrateQueryalready attaches the livepromisefor pending queries; this change ensures the filter doesn't discard them..catch(() => {})— errors are already tracked inside the QueryClient cache, so this purely prevents Node from surfacing an unhandled rejection warning.timeout/skipSsrOnErrorare bypassed whenshouldDehydratePromiseistrue— the component returns theHydrationBoundaryimmediately.On the client,
HydrationBoundaryreceives a dehydrated state that includes pending queries with their promises, and TanStack Query callsquery.fetch({ initialPromise })to subscribe to the streamed result.Only applies to
@suspensive/react-query-5— v4 has no promise dehydration support.