From 3e6ca32c7f27dd1d4e198b8f1f61590f87bba922 Mon Sep 17 00:00:00 2001 From: Idhaya Bastine Kennedy <162452887+IdhayaBastine15@users.noreply.github.com> Date: Sat, 22 Aug 2026 19:35:48 +0100 Subject: [PATCH 1/2] fix(solid-query examples): guard prefetchQuery with isServer in solid-start-streaming --- .../src/routes/prefetch.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/solid/solid-start-streaming/src/routes/prefetch.tsx b/examples/solid/solid-start-streaming/src/routes/prefetch.tsx index 73623302ebb..1463969cf81 100644 --- a/examples/solid/solid-start-streaming/src/routes/prefetch.tsx +++ b/examples/solid/solid-start-streaming/src/routes/prefetch.tsx @@ -1,13 +1,24 @@ import { useQueryClient } from '@tanstack/solid-query' import { isServer } from 'solid-js/web' import { Title } from '@solidjs/meta' +import type { RoutePreloadFuncArgs } from '@solidjs/router' import { UserInfo, userInfoQueryOpts } from '~/components/user-info' export const route = { - load: () => { - const queryClient = useQueryClient() - // Prefetching the user info and caching it for 15 seconds. - queryClient.prefetchQuery(userInfoQueryOpts({ sleep: 500, gcTime: 15000 })) + load: ({ intent }: RoutePreloadFuncArgs) => { + // The router re-runs `load` on the client during hydration, with the + // same `intent: "initial"` the server call gets. UserInfo's useQuery + // already hydrates that data on the client through its own resource, + // so prefetching again here just duplicates the fetch. Hover preload + // (`intent: "preload"`) and real navigation (`intent: "navigate"`) + // still need to run, since neither has server-rendered data to use. + if (isServer || intent !== 'initial') { + const queryClient = useQueryClient() + // Prefetching the user info and caching it for 15 seconds. + queryClient.prefetchQuery( + userInfoQueryOpts({ sleep: 500, gcTime: 15000 }), + ) + } }, } From cedde571bca51906d386b5039bd753427c7d7388 Mon Sep 17 00:00:00 2001 From: Idhaya Bastine Kennedy <162452887+IdhayaBastine15@users.noreply.github.com> Date: Mon, 24 Aug 2026 18:30:29 +0100 Subject: [PATCH 2/2] add empty changeset for #8840 example fix --- .changeset/slimy-peaches-pull.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changeset/slimy-peaches-pull.md diff --git a/.changeset/slimy-peaches-pull.md b/.changeset/slimy-peaches-pull.md new file mode 100644 index 00000000000..e7e11df1bd0 --- /dev/null +++ b/.changeset/slimy-peaches-pull.md @@ -0,0 +1,4 @@ +--- +--- + +fix(solid-query/examples): guard the `prefetchQuery` call in the solid-start-streaming example's `/prefetch` route with `isServer || intent !== 'initial'`, so it only runs on the server and on real client-side preload/navigation, not on every client hydration, fixing the duplicate fetch reported in #8840