You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Max characters for a url is ~2k characters (I think)
Currently the batching lumps everything in a request as /api/trpc/posts.byId,posts.byId.query,posts.byId?batch=1&input=${encodeURIComponent(JSON.stringify(input))}
This could potentially lead to situations where the client constructs a url that is too long.
A few things we could do to prevent this
Change the way we build the query
Given query, this could be built like like /api/trpc/3*posts.byId?batch=x
Make sure the data loader splits up the queries into separate requests when exceeding limit of x
What I don't want to do is to use anything but GET for queries
I'm sending a batch (~300) of UUIDs in a query and it falls over on the server (browser doesn't seem to mind the 25,000 character url lol). It can handle up to 182 UUIDs but any more and it gives me a The page you were looking for cannot be served. error.
Is there currently a way to increase the max query string length? (or is this a Next.js limitation?)
I could rewrite it as a mutation but this would be a huge pain. I know you've said you don't want to use anything but GETs for queries, but is this a valid use case? Maybe if it was opt-in per query?
EDIT: Turns out it's Nginx limiting my URI length. But I'd still like to know your thoughts on why you don't want to use anything other than GET requests :)
I'm sending a batch (~300) of UUIDs in a query and it falls over on the server (browser doesn't seem to mind the 25,000 character url lol). It can handle up to 182 UUIDs but any more and it gives me a The page you were looking for cannot be served. error.
Sounds like you ran into it indeed!
Wow - how come you need to send 300 ids in a query? 😳 Can you explain a bit how this works in your app?
I'm surprised the browser didn't choke on it!
Maybe you can rewrite it as a list query instead somehow?
Is there currently a way to increase the max query string length? (or is this a Next.js limitation?)
I don't think it's a Next.js limitation per se, but rather a Node.js-thing.
I could rewrite it as a mutation but this would be a huge pain. I know you've said you don't want to use anything but GETs for queries, but is this a valid use case? Maybe if it was opt-in per query?
For now, the GET is the only way to do queries, I'll give it a think, maybe we can do a POST query with a ?method=GET-query or something.
I'll give this some thought but I won't pick this up for at least a few days so please see if you can find a way to avoid doing this.
Wow - how come you need to send 300 ids in a query? 😳 Can you explain a bit how this works in your app?
Yeah it's a strange design decision to be sure. It's basically for a long page with hundreds of very small items, of which I only have the id. But I do have a query resolver that takes a long list of ids and gives me all the actual things.
I'm surprised the browser didn't choke on it!
Yeah me too - 300 UUIDs should be about the max so as long as that works I'm happy and will just try not to think about it.
I don't think it's a Next.js limitation per se, but rather a Node.js-thing.
The Node.js limit should be okay for my use case. I discovered it was my Nginx config limiting the size of the uri, so I just upped client_header_buffer_size and large_client_header_buffers and it works 100% fine now!
maybe we can do a POST query with a ?method=GET-query or something.
I am a fan of a good old method override. I think I've come full circle on this though already, because Nginx was the limiting factor, not the browser or node/next/trpc, I don't think this is a big of an issues as I originally thought!
Yeah it's a strange design decision to be sure. It's basically for a long page with hundreds of very small items, of which I only have the id. But I do have a query resolver that takes a long list of ids and gives me all the actual things.
You could also do frontend-only pagination as a workaround or debouncing rendering of the list items responsible for the loading
The Node.js limit should be okay for my use case. I discovered it was my Nginx config limiting the size of the uri, so I just upped client_header_buffer_size and large_client_header_buffers and it works 100% fine now!
Oh, cool!
I am a fan of a good old method override. I think I've come full circle on this though already, because Nginx was the limiting factor, not the browser or node/next/trpc, I don't think this is a big of an issues as I originally thought!
I'm running into this issue as well. Currently I've worked around it with an intersection observer that only loads when the element is in view but something like a httpBatchLink({ maxURILength: 2048 }) or httpBatchLink({ maxBatchSize: 20 }) would be very very helpful.
I've just ran into this as well, is there some work being done on this I can contribute to or maybe a workaround?
My use case is a table with 20-100 rows, and maxBatchSize sounds like the perfect solution.
Activity
[-]Batching - safeguard for max url lengt[/-][+]Batching - safeguard for max url length[/+]alaister commentedon Oct 11, 2021
I just ran into a URL too long error (I think).
I'm sending a batch (~300) of UUIDs in a query and it falls over on the server (browser doesn't seem to mind the 25,000 character url lol). It can handle up to 182 UUIDs but any more and it gives me a
The page you were looking for cannot be served.error.Is there currently a way to increase the max query string length? (or is this a Next.js limitation?)
I could rewrite it as a mutation but this would be a huge pain. I know you've said you don't want to use anything but
GETs for queries, but is this a valid use case? Maybe if it was opt-in per query?EDIT: Turns out it's Nginx limiting my URI length. But I'd still like to know your thoughts on why you don't want to use anything other than
GETrequests :)KATT commentedon Oct 11, 2021
Sounds like you ran into it indeed!
Wow - how come you need to send 300 ids in a query? 😳 Can you explain a bit how this works in your app?
I'm surprised the browser didn't choke on it!
Maybe you can rewrite it as a list query instead somehow?
I don't think it's a Next.js limitation per se, but rather a Node.js-thing.
For now, the
GETis the only way to do queries, I'll give it a think, maybe we can do a POST query with a?method=GET-query or something.I'll give this some thought but I won't pick this up for at least a few days so please see if you can find a way to avoid doing this.
cc @mmkal - a penny for your thoughts 🪙😊
alaister commentedon Oct 11, 2021
Thanks for your prompt response as always!
Yeah it's a strange design decision to be sure. It's basically for a long page with hundreds of very small items, of which I only have the id. But I do have a query resolver that takes a long list of ids and gives me all the actual things.
Yeah me too - 300 UUIDs should be about the max so as long as that works I'm happy and will just try not to think about it.
The Node.js limit should be okay for my use case. I discovered it was my Nginx config limiting the size of the uri, so I just upped
client_header_buffer_sizeandlarge_client_header_buffersand it works 100% fine now!I am a fan of a good old method override. I think I've come full circle on this though already, because Nginx was the limiting factor, not the browser or node/next/trpc, I don't think this is a big of an issues as I originally thought!
KATT commentedon Oct 11, 2021
You could also do frontend-only pagination as a workaround or debouncing rendering of the list items responsible for the loading
Oh, cool!
Will take this into consideration!
ecwyne commentedon Dec 30, 2021
I'm running into this issue as well. Currently I've worked around it with an intersection observer that only loads when the element is in view but something like a
httpBatchLink({ maxURILength: 2048 })orhttpBatchLink({ maxBatchSize: 20 })would be very very helpful.darioielardi commentedon Jan 19, 2022
I've just ran into this as well, is there some work being done on this I can contribute to or maybe a workaround?
My use case is a table with 20-100 rows, and
maxBatchSizesounds like the perfect solution.KATT commentedon Jan 19, 2022
Yes! Here's some rough steps:
maxBatchSize?: numbertohttpBatchLinkinterface HTTPBatchLinkOptions extends HTTPLinkOptions { maxBatchSize?: number }opts?: { maxBatchSize?: number }to https://github.com/trpc/trpc/blob/main/packages/client/src/internals/dataLoader.ts#L23httpBatchLinktodataLoader(trpc/packages/client/src/links/httpBatchLink.ts
Lines 40 to 42 in 7156882
dispatch()if length exceedsmaxBatchSizehere: https://github.com/trpc/trpc/blob/main/packages/client/src/internals/dataLoader.ts#L71KATT commentedon Jan 28, 2022
Fixed by #1468
KATT commentedon Jan 28, 2022
https://github.com/trpc/trpc/releases/tag/v9.18.0
github-actions commentedon Oct 4, 2022
This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.