Skip to content
Source
Sign inSign up
TanStack/query

fix(solid-query): enable experimental_prefetchInRender by default for… #9822

Mergedbirkskyum(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/9822/headmerged 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. 🦋 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
      NameType
      @tanstack/solid-queryPatch
      @tanstack/solid-query-devtoolsPatch
      @tanstack/solid-query-persist-clientPatch

      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

    2. Walkthrough

      Enables SSR prefetch during render in Solid Query by setting experimental_prefetchInRender = true on server-side default options inside useBaseQuery, changing SSR fetch timing to run during render (to support createResource) instead of waiting for effects.

      Changes

      Cohort / File(s)Change Summary
      SSR Prefetch Configuration
      packages/solid-query/src/useBaseQuery.ts
      On the server execution path, sets defaultOptions.experimental_prefetchInRender = true and adds comments explaining the change; alters SSR behavior so queries prefetch during render to support createResource rather than waiting for effects.
      Release metadata
      .changeset/thirty-poems-yell.md
      Adds a changeset marking a patch release that documents enabling experimental_prefetchInRender on 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
        end

      Estimated code review effort

      🎯 3 (Moderate) | ⏱️ ~20 minutes

      • Inspect useBaseQuery server-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 .changeset metadata for correct release tagging.
      • TanStack/query#9576 — Changes related to experimental_prefetchInRender and lazy rejection behavior in query-core; directly related to prefetch promise behavior.
      • TanStack/query#9772 — Enables experimental_prefetchInRender by 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 nameStatusExplanationResolution
      Description Check⚠️ WarningThe 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 nameStatusExplanation
      Title Check✅ PassedThe 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✅ PassedThe 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✅ PassedAll 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✅ PassedDocstring 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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    3. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-query

    4. View your CI Pipeline Execution ↗ for commit b84bbeb67e46f42f74b8b5013e36cd9cae14a0d9

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 56sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded2sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-11-01 14:35:08 UTC

    5. More templates

      @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@9822

      commit: b84bbeb

    6. Sizes for commit b84bbeb67e46f42f74b8b5013e36cd9cae14a0d9:

      BranchBundle Size
      Main
      This PR
    7. Codecov Report

      :x: Patch coverage is 0% with 1 line in 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

      Impacted file tree graph

      @@             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      -431     
      ComponentsCoverage Δ
      @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-query77.81% <0.00%> (-0.26%):arrow_down:
      @tanstack/solid-query-devtools61.90% <ø> (ø)
      @tanstack/solid-query-persist-client100.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.