zrilman
zrilman2y ago

Input is too big for a single dispatch

I decided to try tRPC for my Crypto analytics dashboard. However, I'm having a hard time passing the time series data between the client & the server. First I received an HTTP error Request header too large I was able to fix this by setting maxURLLength However, now I receive another error "Input is too big for a single dispatch" So my question does tRPC even support such queries, where you send long arrays of data as inputs?
6 Replies
Nick
Nick2y ago
Is this is a query? Might be worth trying a mutation instead, tRPC currently uses GET for queries and that has limitations
zrilman
zrilmanOP2y ago
Yes. It's a query. I've ended up with switching to mutation 😄
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Nick
Nick2y ago
Yeah this is a limitation right now AFAIK, there is chatter about making queries more flexible, like using a POST under the hood, just not sure where the core team are with that. In general though, sending a large amount of data by a query is probably a code-smell. I am aware there are some legit use cases though
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
isaac_way
isaac_way2y ago
It's pretty easy to just wrap a mutation call in a react query useQuery hook, probably the simplest workaround I think:
import {useQuery} from '@tanstack/react-query';

function usePostsQuery() {
const client = api.useContext().client;
return useQuery({queryFn: async ()=>{
return await client.posts.getPosts.mutate();
}})
}
import {useQuery} from '@tanstack/react-query';

function usePostsQuery() {
const client = api.useContext().client;
return useQuery({queryFn: async ()=>{
return await client.posts.getPosts.mutate();
}})
}