ibrahimyaacob
ibrahimyaacob3w ago

How to catch too many bytes read in a single function execution error ?

i have a query function that performs multiple queries below.
export const queryfunction = query({

// expensive query 1
const result1 = await ctx.db("..")

// expensive query 2
const result2 = await ctx.db("..")

})
export const queryfunction = query({

// expensive query 1
const result1 = await ctx.db("..")

// expensive query 2
const result2 = await ctx.db("..")

})
right now im trying to understand if the the too many bytes read in a single function is caused by a single db query or is it triggered by sum of that multiple queries? if its the later, how do i catch it in serverside ?
5 Replies
Convex Bot
Convex Bot3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart3w ago
You can try/catch each ctx.db call to find out where it's going over Oh hmm yeah I wonder if that would actually work, might not depending on how that error happens. I suspect you don't have the option of just handling it the typical way. But maybe if you log after each ctx.db call the logs will still print? You could test by logging at the top of the function.
sshader
sshader3w ago
Yeah I don't think there's currently an easy way to catch the error (also not really a way to get partial log lines if the query fails). We've had some ideas floating around on how to make it easier to debug usage within a query One potential strategy would be to use the "Custom test query" in the dashboard to replicate parts of your query and see when it hits the limit (or when you start getting warning log lines about approaching the limit) -- https://docs.convex.dev/dashboard/deployments/data#writing-custom-queries
Data | Convex Developer Hub
Data Dashboard Page
ibrahimyaacob
ibrahimyaacobOP2w ago
hey @sshader in my case, im using convex ents to perform insert many on a scheduler before it crashes. we really need a way to catch this function level error properly, preferably within the same function. something like this
export const myfunc = mutation({
args:...
handler:...
onTooManyByteReadError: () => {
// handling error
}
})
export const myfunc = mutation({
args:...
handler:...
onTooManyByteReadError: () => {
// handling error
}
})
erquhart
erquhart2w ago
In case it helps, if you're still trying to determine which part of your query is causing a problem, I would remove parts of the query running locally until it passes to find the offending portion. That way you can troubleshoot within your existing code with ents.

Did you find this page helpful?