Skip to content

fix(solid-query): await SSR status reads - #11468

Open
ousamabenyounes wants to merge 2 commits into
TanStack:mainfrom
ousamabenyounes:fix/issue-10751
Open

ousamabenyounes wants to merge 2 commits into
TanStack:mainfrom
ousamabenyounes:fix/issue-10751

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Changes

Fixes #10751.

Solid Query's server proxy returned status properties before the query resource participated in async SSR, so a curried queryOptions accessor could render the pending branch even though the query completed and was dehydrated.

This change makes pending, non-function status reads join the resource lifecycle during server rendering while preserving the existing data path. It also adds real Vite SSR regressions for curried options and initial data during a background fetch.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 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

  • Bug Fixes

    • Server-rendered Solid Query status branches now wait for curried queries to resolve before rendering, so they reflect the query’s resolved state.
    • Queries with initial data render immediately without unnecessarily waiting for a server refetch.
  • Tests

    • Added server-side rendering coverage for pending, error, success, and initial-data query states, including checks that initial data is available without waiting for a refetch.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: aa28213c-2734-4334-8836-73536512a345

📥 Commits

Reviewing files that changed from the base of the PR and between bf57191 and f305d55.

📒 Files selected for processing (1)
  • packages/solid-query/src/useBaseQuery.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Solid Query now reads the pending server query resource before returning a non-function property from the query result proxy. New SSR fixtures and tests cover curried queries, initial data, query function counts, and coverage forwarding. A changeset records a patch release.

Changes

Solid SSR query handling

Layer / File(s) Summary
Pending resource read during SSR
packages/solid-query/src/useBaseQuery.ts
The query result proxy reads queryResource() on the server when the query is pending and the accessed property is not a function.
SSR regression validation
packages/solid-query/src/__tests__/fixtures/ssr-entry.tsx, packages/solid-query/src/__tests__/ssr.test.ts, .changeset/curried-query-ssr.md
The fixture renders query status branches and initial data. Vite-based tests verify rendered markup and query function counts, and forward SSR coverage counters when available. A patch changeset records the SSR behavior change.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: lachlancollins

Merge Risk: ⚪ Minimal · up to f305d

Pending SSR query status reads join the Suspense lifecycle so rendering can show the resolved branch. No actionable merge risk was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to f305d

The change affects 1 system.

Changed systems: packages/solid-query

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/solid-query (library) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/solid-query/src/tests/fixtures/ssr-entry.tsx: New file ssr-entry.tsx adds a Solid SSR test fixture with render (using renderToStringAsync, a QueryClientProvider, Suspense fallback, and a Switch/Match component reflecting query.isPending, query.isError, and query.isSuccess states) and renderWithInitialData (a query with initialData returning initialQueryResult), both returning { markup, queryFnCalls }, tracking queryFn call counts, and clearing the QueryClient in a finally block; it also exports getCoverage reading __VITEST_COVERAGE__ from globalThis and constants expectedQueryResult, initialQueryResult, and successLabel.
  • observed — Modified behavior in packages/solid-query/src/tests/ssr.test.ts: Adds imports, path constants, and resolves the istanbul instrumenter and solid-js server entry points via createRequire.
  • observed — Modified behavior in packages/solid-query/src/tests/ssr.test.ts: Adds createSsrCoveragePlugin, a Vite plugin that instruments useBaseQuery.ts source with istanbul coverage and returns the instrumented code with its source map.
  • observed — Modified behavior in packages/solid-query/src/tests/ssr.test.ts: Adds a describe block whose beforeAll creates a Vite dev server with the solid plugin, coverage plugin, solid-js server aliases, node resolve conditions, and middleware mode, closing it in afterAll.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: awaiting Solid Query SSR status reads.
Description check ✅ Passed The description includes all required sections, explains the fix and motivation, documents testing, and confirms the changeset. The AI checklist item does not explicitly mention following the AI contr…
Linked Issues check ✅ Passed For the SSR status-rendering case in #10751, the PR meets the coding objective. useBaseQuery.ts now calls queryResource() when a pending server query exposes a non-function status property. The Vi…
Out of Scope Changes check ✅ Passed The changeset, useBaseQuery.ts change, SSR fixture, and SSR tests all support the curried-query SSR fix for #10751. No unrelated product behavior or unrelated files are changed.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

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

@ousamabenyounes ousamabenyounes changed the title fix(solid-query): await SSR status reads 🤖🤖🤖 fix(solid-query): await SSR status reads Sep 10, 2026
@changeset-bot

changeset-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f305d55

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

This PR includes changesets to release 24 packages
Name Type
@tanstack/solid-query Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query-persist-client Patch
@tanstack/angular-query-experimental Patch
@tanstack/eslint-plugin-query Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-core Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/react-query-persist-client Patch
@tanstack/react-query Patch
@tanstack/vue-query Patch
@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

This branch has not been deployed

No deployments
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.

queryOptions built via currying breaks SolidJS' Reactivity

1 participant