#Uncaught ConvexError in NextJS Logs (Development)

7 messages · Page 1 of 1 (latest)

snow folio
#

I'm throwing a ConvexError in my mutation. In the frontend I wrap the mutation with a try..catch block, try to parse the error to a ConvexError and then show a toast with the message. This all works fine but I still get the following error log. Is this intended behavior?

CONVEX M(tasks/create)] [Request ID: 040bcfe7b4c31f57] Server Error
Uncaught ConvexError: {"code":"TASK_LIMIT_EXCEEDED","limit":10}
    at handler (../../convex/tasks/create.ts:18:8)
alpine fiberBOT
#

Hi @snow folio. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, that log line is expected in development.

Convex logs every function execution and every error thrown by your functions on the backend. Those logs show up:

  • In your browser devtools console when using ConvexReactClient in dev
  • In the Convex dashboard Logs page
  • In your terminal when running npx convex dev [Debugging]

Catching the error in your Next.js code only affects the client-side behavior (e.g. showing a toast). It does not suppress the server-side log entry for the thrown ConvexError. Convex still records:

  • The function name (tasks/create)
  • The request ID
  • The fact that a ConvexError was thrown, including its data payload [Application errors]

So:

  • Your current pattern (throw ConvexError in the mutation, try/catch on the client, show toast) is correct.
  • Seeing Uncaught ConvexError: {...} in the Convex logs in development is normal and intended. In production, full details are only in the logs; the client just sees a generic "Server Error" for non-application errors, while ConvexError still carries its data [Dev vs prod errors].

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@snow folio Kapa.ai is still learning and improving, please let me know how I did by reacting below.

snow folio
#

@alpine fiber The error log happens on the client, I can see it in the browser logs. That's what's irritating me.

alpine fiberBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

You’re seeing that in the browser because Convex forwards server logs to the client in development.

When you use ConvexReactClient against a dev deployment, Convex:

  • Logs all successful function executions and all errors on the backend.
  • Then sends those logs to the client, and the client prints them into the browser console. [Debugging]

So even if you:

try {
  await createTask(...);
} catch (err) {
  // handle ConvexError here
}

the server still logs the thrown ConvexError, and that log is mirrored into your browser console in dev. Catching the error on the client only prevents an unhandled promise rejection in your app; it does not suppress the Convex server log.

This mirroring of logs to the browser only happens in dev; production deployments do not send logs to the client. [Debugging; Dev vs prod errors]

So yes: seeing that “Uncaught ConvexError …” line in the browser console in development is intended behavior, even when you catch and handle the error in your Next.js code.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: