Skip to content
Source
Sign inSign up
TanStack/query

solid-query v6: useQuery shows only the first chunk of a streamedQuery until the stream ends #12665

Send to my agent
Openlodgekeeper(GitHub profile, opens in a new tab) opened this issue 0 comments

Describe the bug

With @tanstack/solid-query 6.0.0-rc.6, a useQuery whose queryFn comes from experimental_streamedQuery shows the first chunk and then nothing more until the stream ends. The cache gets every chunk as it arrives, but query.data keeps the first one. On a refetch no chunk shows until the stream ends, in each refetchMode. Reading through latest(() => query.data) gives the same. With @tanstack/solid-query 5.108.2 on solid-js 1.9 the same query shows each chunk as it arrives.

It seems to come from computeData in useBaseQuery.ts: while fetchStatus is not idle and a value is already committed, it returns query.promise, so the data node waits for the whole fetch. For a streamed query the fetch is the whole stream. A setQueryData made during an ordinary refetch is held the same way.

Is this intended for v6? If it is, the page for experimental_streamedQuery could say that useQuery shows the result only when the stream ends. For now we read the chunks with a QueryObserver from query-core.

Your minimal, reproducible example

The component under "Steps to reproduce"

Steps to reproduce

Render this and watch the paragraph. I ran it in vitest with jsdom and read textContent and client.getQueryData(["chunks"]) every 25 ms.

const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));

function Chunks() {
  const query = useQuery(() => ({
    queryKey: ["chunks"],
    queryFn: experimental_streamedQuery({
      async *streamFn() {
        for (const chunk of ["a", "b", "c"]) {
          await wait(50);
          yield chunk;
        }
      },
    }),
  }));
  return <p>{query.data.join(" ")}</p>;
}

render(
  () => (
    <QueryClientProvider client={client}>
      <Loading fallback="loading">
        <Chunks />
      </Loading>
    </QueryClientProvider>
  ),
  el,
);
AfterCachePage
50 msaa
100 msa ba
150 msa b ca b c

Expected behavior

The page shows a, then a b, then a b c, as the cache does.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Node.js 26, vitest 5.1.0 with jsdom 31

Tanstack Query adapter

solid-query

TanStack Query version

6.0.0-rc.6 (query-core 5.107.1, solid-js 2.0.3)

TypeScript version

No response

Additional context

No response

  1. tanstack-source added labelsbug

Sign in to join this conversation.