balakayB
tRPC2y ago
2 replies
balakay

UseQuery iterator not working for me

I am on tRPC v11. Using the example provided in the documentation under "streaming responses using async generators" (re: https://trpc.io/docs/client/react/useQuery) I get the following error in the client:

Cannot use stream-like response in non-streaming request - use httpBatchStreamLink


Any idea where I might be going wrong or if there are some configs I need to change?

Server
const t = initTRPC.context<ExpressContext>().create({
  experimental: {
    iterablesAndDeferreds: true,
  },
});
//...
test: appProc.query(async function* () {
  for (let i = 0; i < 10; i++) {
    await sleep(1000); 
    yield i;
  }
}),


Client
export const trpc = createTRPCReact<AppRouter>();
//...
const iterable = trpc./*...*/.test.useQuery();
Was this page helpful?