#Uncaught error when trying to sign in?

10 messages · Page 1 of 1 (latest)

tardy python
#

I have this code, taken almost directly from the docs:

signIn("password", formData)
                    .then(() => {
                      setSuccess(
                        step === "signIn"
                          ? "Logged in successfully!"
                          : "Account created successfully!"
                      )
                      router.push("/")
                    })
                    .catch((err) => {
                      if (
                        err instanceof ConvexError
                      ) {
                        setError(
                          err.message || "An error occurred. Please try again."
                        )
                      }
                    })

But it keeps giving me these errors:

[CONVEX A(auth:signIn)] [Request ID: 4a1e6e5aac97d34e] Server Error
Uncaught Error: Invalid password
[CONVEX A(auth:signIn)] [Request ID: d05930db678be120] Server Error
Uncaught Error: InvalidSecret

I'm catching these errors. What do I do?

proven yarrowBOT
#

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

#

Looking at your code, the issue is that you're catching the error but checking err instanceof ConvexError — however, the errors thrown by auth:signIn (like "Invalid password" or "InvalidSecret") are not ConvexError instances. They are standard Error objects thrown by the Convex Auth internals.

Your .catch block silently does nothing when the error isn't a ConvexError, which means the error appears "uncaught" in the console even though your .catch is there.

Fix: Also handle plain Error instances in your catch block:

signIn("password", formData)
  .then(() => {
    setSuccess(
      step === "signIn"
        ? "Logged in successfully!"
        : "Account created successfully!"
    );
    router.push("/");
  })
  .catch((err) => {
    if (err instanceof ConvexError) {
      setError(err.data || err.message || "An error occurred. Please try again.");
    } else if (err instanceof Error) {
      setError(err.message || "An error occurred. Please try again.");
    }
  });

A few additional things to check:

  1. Make sure you're on the latest version of Convex Auth. There was a known bug in older versions where errors from signIn were not properly propagated to the client. Updating fixed it: [Convex Auth debugging]

    npm install @convex-dev/auth@latest
    
  2. Enable verbose logging to get more detail on what's happening: [Auth debugging]

    npx convex env set AUTH_LOG_LEVEL DEBUG
    

    And on the client:

    const client = new ConvexReactClient(process.env.CONVEX_URL, { verbose: true });
    
#

The "Invalid password" and "InvalidSecret" errors are expected auth failures (e.g., wrong password entered), so once your catch block handles plain Error objects, you should be able to display them to the user correctly.

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

#

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

tardy python
#

@kapa This is the error message:

[CONVEX A(auth:signIn)] [Request ID: f07dfca79b7357d0] Server Error Uncaught Error: InvalidAccountId Called by client

It's not readable at all

#

@proven yarrow This is the error message:

[CONVEX A(auth:signIn)] [Request ID: f07dfca79b7357d0] Server Error Uncaught Error: InvalidAccountId Called by client

It's not readable at all

proven yarrowBOT
#

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

#

The error message Uncaught Error: InvalidAccountId is coming from the Convex backend, and as noted in the Convex docs, in production deployments, server errors are redacted to a generic message — but in dev, you get the full error. [Error reporting]

To get more readable/detailed information about what's going wrong, here's what you can do:

1. Check the Convex Dashboard Logs

The full error with stack trace is always available on the Logs page of your deployment. You can paste the Request ID (f07dfca79b7357d0) directly into the dashboard to find the exact logs for that request. [Finding logs by Request ID]

2. Enable Verbose Logging

Enable AUTH_LOG_LEVEL to get more detail from Convex Auth internals: [Auth debugging]

npx convex env set AUTH_LOG_LEVEL DEBUG

And on the client:

const client = new ConvexReactClient(process.env.CONVEX_URL, { verbose: true });

3. What InvalidAccountId likely means

This error suggests that during the sign-in flow, Convex Auth is unable to find or resolve the account associated with the credentials being passed. This could be caused by:

  • Passing incorrect or mismatched form data (e.g., wrong field names)
  • A mismatch between the flow value and the actual state of the account

Check that your form fields match what the Password provider expects (e.g., email, password, flow). [Password provider]

#

The dashboard logs with the Request ID will give you the most actionable detail on the root cause.

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