Cannot read properties of null (reading 'redirect') in @convex-dev/auth/react `signIn` function
I am encountering a
TypeError: Cannot read properties of null (reading 'redirect')
when calling the signIn
function from @convex-dev/auth/react in my Next.js application. The error occurs at the line where await signIn("password", formData)
is called, and the stack trace points to an internal client.js file within the @convex-dev/auth library.
I have already tried the following:
- Ensured formData.set("redirectTo", "/dashboard") is passed to the signIn function (even if I remove the "redirectTo" it still gave me redirect error).
- Verified that my CONVEX_SITE_URL env is correctly set in my Convex deployment.
The error consistently points to an attempt to read a redirect property from a null object within the @convex-dev/auth/react library's internal code.27 Replies
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!
That would be this line here: https://github.com/get-convex/convex-auth/blob/e4a9e0e7de0da9160185ac0028cfb684a9bcd147/src/react/client.tsx#L242
Which is unexpected, the
auth:signIn
action would have to return null
And that isn't really a thing: https://github.com/get-convex/convex-auth/blob/e4a9e0e7de0da9160185ac0028cfb684a9bcd147/src/server/implementation/index.ts#L420-L432
Can you enable verbose logging and share logs generated around thisafter looking and checking I can confirm that it's totally my fault.
I have a Account table which hold user data but I confused it with my authAccount
sorry.
Ah, glad you figured it out!
that was a head scratcher lol
Thanks a lot 🙇
Has anyone found the fix for this ?
I dont think this issue has been fixed. I'm getting this error 'Cannot read properties of null (reading 'redirect')' in the signIn function. The issue I have noticed is that the ConvexError thrown in the auth.ts file is not being caught here in the client.
I did enable the vorbose logging using the 'AUTH_LOG_LEVEL' in the convex dashboard. Following is what i'm getting...

this is thrown in the auth.ts file when the email is not valid

however the client is actually logging some other error

Can you follow the first enable verbose logging step so the client does it as well? Might give us more info. If you look through my earlier replies, I don't currently see a code path capable of this error, so trying to figure out what I'm missing when this happens.
FYI, this is in the development mode !!
I understand this. If you can respond to my last message I can help further here
A quick fix is to use
error as unkown as Error
since it's a typescript thing,
And i suggest moving the .then
statment before the catch, since this is how the asynchronous functions work, data first, error after
(Referring to the second screenshot)Hello could you help? Is it ok to use open ai api key in making app for the competition?
I have enabled the the verbose logging. The documentation says 'Logs will appear in the browser console when you run your app.' The browser console just loggs the hyderation errror which I get all the time and then the same error message 'Cannot read properties of null (reading 'redirect')'. Not sure if i'm missing anything here.


Let's focus on the error you're getting on the backend first. Your custom profile function is throwing a ConvexError understood to mean the email address is invalid. Based on the screenshot you're sharing, you're entering an invalid email, but I'm guessing you've tried a valid one too. Can we confirm why your Zod parsing is throwing? Eg., you want to confirm whether it's taking a valid email address and calling it invalid for some reason.
I did try this with a valid email and in doing so, there is no error thrown and the user is then logged in to a desired page. No issues there !!! as you can see from the screenshot below

I chanced upon this link https://discordapp.com/channels/1019350475847499849/1388409198089338900/1388409198089338900
or is it something which is a known issue especially when using Password as provider. And the fix is yet to be provided ??
I haven't been able to reproduce this, if someone has a public repo with this issue I can definitely dig into it.
GitHub
GitHub - bbasnett/convex-passoword-provider
Contribute to bbasnett/convex-passoword-provider development by creating an account on GitHub.
Running this locally and things are working, no errors
Thanks for checking out the repo. There are no error as such with running the application. The issue is that when I included the email and password validation in the auth.ts file, I'm expecting the ConvexError to be propogated to the client sign 'signIn' function when the user provides an invalid email format. However, the error that is actually seen is something else as indicated in the image.
I have a new commit in the repo ..

When the user provides a valid email format and passoword, the user is successfully registered and then redirect to the authorized page.
@Bikash and anyone else running into this: please use the latest version of Convex Auth, this bug is only present in older versions.
npm install @convex-dev/auth@latest