tRPCttRPC
Powered by
balakayB
tRPC•2y 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
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;
  }
}),
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();
export const trpc = createTRPCReact<AppRouter>();
//...
const iterable = trpc./*...*/.test.useQuery();
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Cache not working for `useQuery`
JokcyJJokcy / ❓-help
3y ago
`useQuery` not working?
SansPapyrus683SSansPapyrus683 / ❓-help
3y ago
useQuery enabled not working???
taylor.prestoTtaylor.presto / ❓-help
4y ago