"Log line is too long" on seemingly simple query on small table.
Hey gang! Our team is absolutely loving building on top of convex. We are actually in the process of moving our entire application/business onto the platform.
I am having an unusual issue though today. Out of seemingly nowhere (said every developer ever) a function that was working has stopped. I traced it down to the following query but cannot figure out what the issues is.
const ga = await ctx.db.query("group_attributes").take(16);
and here is the "group_attributes" table schema:
group_attributes: defineTable({
organization_id: v.id("organizations"),
name: v.string(),
parent_group_id: v.id("groups"),
ref_group_id: v.optional(v.id("groups")),
type: v.string(),
meta: v.optional(v.any()),
}).index("by_organization_id_parent_group_id", [
"organization_id",
"parent_group_id",
]),
I have stripped verything else out of the parent funciton to the above query and even stripped the query down to its most basic form (removed indexes then filters to just "take" becasue collect() was erroring out). The query works if take is set to 15 but errors out for anything greater.
The corresponding "group_attriubtes" table only has 97 documents in it so I have a hard time seeing how this could be timeout related. Plus, putting other queries before it in the function (which would theoretically decrease the time available to run the query) do not effect the take(15) cutoff.
The query shows the following error in the convex logs:
failure
Uncaught Error: Log line is too long (4224 > maximum length 4096)
at handler (../convex/blocks.ts:47:11)
I have been troubleshooting this all morning and it's starting to push other tasks back... so naturally I figured I would ask the experts.3 Replies
So I believe what is happening here is that there's a log line somewhere like
console.log(queryResults)
where that log line is hitting a limit we've set internally which is causing the entire function to fail (which is definitely an issue on our end).
Does that sound like what could be happening?
To try and unblock you, I think splitting things into multiple console.log
statements or only logging certain attributes might help? (but also we should fix the issue of log lines causing the whole request to fail)sshader! thank you! removing any console.logs did solve the problem. I will say though that the quoted "log lines" seems higher than what this query would have generated... but I am not super confident. Moving forward I will keep my console logs to a minimum!
I'm also working on fixing this on our end (truncating instead of failing) since it's definitely not great that a log line can suddenly cause an app to break (so ideally you can have as many log lines as you want)
I agree that it seems a little surprising that 16 fairly small items is enough to hit this limit. My best guess is that when logging an array, our limit applies to the total length of the logged array vs. per element.