fix(solid-query): enable experimental_prefetchInRender by default for… #9822
main fromrefs/pull/9822/head·merged by TkDodo closes https://github.com/TanStack/query/issues/9713
Solid query on the server hangs forever, because it always needs experimental_prefetchInRender:true on the server, but that's off by default. Since it always have to be on on the server, this PR detects isServer and set it true. It's because createResource uses promises.
Summary by CodeRabbit#
- Enhancements
- Enabled experimental "prefetch in render" by default during server-side rendering to fetch data earlier in the render cycle — improving data availability, reducing SSR wait times, and producing more consistent initial renders for SSR pages.
- Released a patch that rolls out this SSR prefetch behavior change.
- 1
Walkthrough#
Enables SSR prefetch during render in Solid Query by setting
experimental_prefetchInRender = trueon server-side default options insideuseBaseQuery, changing SSR fetch timing to run during render (to supportcreateResource) instead of waiting for effects.Changes#
Cohort / File(s) Change Summary SSR Prefetch Configuration packages/solid-query/src/useBaseQuery.tsOn the server execution path, sets defaultOptions.experimental_prefetchInRender = trueand adds comments explaining the change; alters SSR behavior so queries prefetch during render to supportcreateResourcerather than waiting for effects.Release metadata .changeset/thirty-poems-yell.mdAdds a changeset marking a patch release that documents enabling experimental_prefetchInRenderon server render.Sequence Diagram(s)#
sequenceDiagram participant Server participant useBaseQuery participant QueryClient participant createResource rect rgb(240,248,255) Server->>useBaseQuery: render() (server path) useBaseQuery->>QueryClient: set defaultOptions.experimental_prefetchInRender = true useBaseQuery->>QueryClient: prefetch query during render (sync-ish) QueryClient-->>useBaseQuery: returns promise/observable useBaseQuery->>createResource: provide data/promise to createResource during render createResource-->>Server: suspends/resolves for SSR output endEstimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
- Inspect
useBaseQueryserver-only branching to confirm the flag is applied only on server paths. - Validate comments and option mutation don't leak into client defaults.
- Review SSR test coverage and any integrations relying on prior effects-based fetch timing (e.g., Astro integration).
- Check
.changesetmetadata for correct release tagging.
Possibly related PRs#
- TanStack/query#9576 — Changes related to
experimental_prefetchInRenderand lazy rejection behavior in query-core; directly related to prefetch promise behavior. - TanStack/query#9772 — Enables
experimental_prefetchInRenderby default for server-side rendering in core; closely connected to this adapter-side change.
Poem#
🐰 In server-render burrows I hop with delight,
prefetchInRender< now turns on the light,
createResource wakes while I softly nibble code, SSR no longer waits on effects' slow road, Hooray — fast renders, carrot-shaped and bright! 🥕✨
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
Check name Status Explanation Resolution Description Check ⚠️ Warning The pull request description provides a brief explanation of the problem and solution but does not follow the required template structure. The template specifies three main sections: "🎯 Changes" with motivation, "✅ Checklist" with verification steps, and "🚀 Release Impact" declaring whether the change affects published code. The actual description lacks all these structured sections, the checklist items, and does not explicitly declare that a changeset was generated (though one was included). While the descriptive content is relevant and explains the technical issue adequately, the complete absence of the required template format and checklist items constitutes a failure to meet the repository's contribution standards. The PR description should be updated to follow the template format. Add the "🎯 Changes" section with the detailed explanation of changes and motivation, include the "✅ Checklist" with checkboxes confirming the contributing guide was followed and tests were run (mark as completed if already done), and add the "🚀 Release Impact" section to document that this change affects published code and that a changeset was generated. This ensures consistency with repository standards and allows reviewers to quickly verify that proper development practices were followed. ✅ Passed checks (4 passed)
Check name Status Explanation Title Check ✅ Passed The pull request title "fix(solid-query): enable experimental_prefetchInRender by default for…" clearly summarizes the main change in the PR. It specifies the package being fixed (solid-query), the type of change (fix), and the primary objective (enabling experimental_prefetchInRender by default). The title accurately reflects the code modifications to useBaseQuery.ts and the corresponding changeset, making it easy for reviewers scanning history to understand the change at a glance. Linked Issues Check ✅ Passed The code changes directly address the requirements specified in linked issue #9713. The modification to useBaseQuery.ts implements the non-breaking solution requested by enabling experimental_prefetchInRender on the server path when isServer is detected. This approach automatically enables the required behavior during server rendering without requiring manual configuration, which resolves the SSR hang issue caused by Solid Query's createResource using promises. The addition of the changeset properly documents the release impact, and the implementation matches the workaround (setting experimental_prefetchInRender: true) that was confirmed to fix the problem in the issue. Out of Scope Changes Check ✅ Passed All changes in the pull request are directly related to the stated objective of enabling experimental_prefetchInRender by default during server rendering. The modification to packages/solid-query/src/useBaseQuery.ts implements the core requirement by detecting the server environment and setting experimental_prefetchInRender to true, which addresses the SSR hang in issue #9713. The addition of .changeset/thirty-poems-yell.md properly documents the release impact as a patch version bump for @tanstack/solid-query. No extraneous or unrelated changes are present in this PR. Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. ✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch `enable-experimental_prefetchInRender-by-default-for-solid`
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between bedefb6ac955165cecba475690fa88abafccbab7 and b84bbeb67e46f42f74b8b5013e36cd9cae14a0d9.
📒 Files selected for processing (1)
.changeset/thirty-poems-yell.md(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .changeset/thirty-poems-yell.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
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.
Comment `@coderabbitai help` to get the list of available commands and usage tips.- Inspect
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-query
View your CI Pipeline Execution ↗ for commit b84bbeb67e46f42f74b8b5013e36cd9cae14a0d9
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 1m 56s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2025-11-01 14:35:08UTCMore templates
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9822@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9822@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9822@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9822@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@9822@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@9822@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9822@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9822@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@9822@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@9822@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9822@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9822@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@9822@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9822@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9822@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@9822@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9822@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9822@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@9822@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9822commit:
b84bbebCodecov Report#
:x: Patch coverage is
0%with1 linein your changes missing coverage. Please review. :white_check_mark: Project coverage is 76.39%. Comparing base (38b4008) to head (b84bbeb). :warning: Report is 4 commits behind head on main.Additional details and impacted files
@@ Coverage Diff @@ ## main #9822 +/- ## =========================================== + Coverage 45.74% 76.39% +30.65% =========================================== Files 200 19 -181 Lines 8404 394 -8010 Branches 1919 81 -1838 =========================================== - Hits 3844 301 -3543 + Misses 4112 76 -4036 + Partials 448 17 -431Components Coverage Δ @tanstack/angular-query-experimental ∅ <ø> (∅)@tanstack/eslint-plugin-query ∅ <ø> (∅)@tanstack/query-async-storage-persister ∅ <ø> (∅)@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)@tanstack/query-codemods ∅ <ø> (∅)@tanstack/query-core ∅ <ø> (∅)@tanstack/query-devtools ∅ <ø> (∅)@tanstack/query-persist-client-core ∅ <ø> (∅)@tanstack/query-sync-storage-persister ∅ <ø> (∅)@tanstack/query-test-utils ∅ <ø> (∅)@tanstack/react-query ∅ <ø> (∅)@tanstack/react-query-devtools ∅ <ø> (∅)@tanstack/react-query-next-experimental ∅ <ø> (∅)@tanstack/react-query-persist-client ∅ <ø> (∅)@tanstack/solid-query 77.81% <0.00%> (-0.26%):arrow_down: @tanstack/solid-query-devtools 61.90% <ø> (ø)@tanstack/solid-query-persist-client 100.00% <ø> (ø)@tanstack/svelte-query ∅ <ø> (∅)@tanstack/svelte-query-devtools ∅ <ø> (∅)@tanstack/svelte-query-persist-client ∅ <ø> (∅)@tanstack/vue-query ∅ <ø> (∅)@tanstack/vue-query-devtools ∅ <ø> (∅):rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
TkDodo approved these changes
TkDodo merged this6ebee2e
TkDodo closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: b84bbeb67e46f42f74b8b5013e36cd9cae14a0d9
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
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