I get a very strange error in production
I get a very strange error in production but I don't get how to get its logs, vercel doesn't show anything
convex dashboard doesn't show anything in its functions too
anyone know what I can do in such cases?

85 Replies
this only happens in production
I think you imported an Convex server function into the client
interesting, can you help understand where I can import it
https://github.com/genxai/new
im checking
sign-in route nowCan't find the root cause but I would check in local env, I had this issues once and my console was getting error log. I'd start debugging from there.
is there env responsible for server fn in convex
mby i missed adding it in vercel
but I think I added everything
Using Convex with Vercel | Convex Developer Hub
Host your frontend on Vercel and your backend on Convex
oh this doc I read, I think I got all envs from there
ok i think that maybe the cause as I do use custom domain

checking it more now
only thing its unclear what
CONVEX_CLOUD_URL should beHi, I don't know who wrote the entire repo, but when I first saw it, to me it looked like an AI wrote the entire thing, This is why i seriously recommend that you learn what you're doing before implementing it, at least by a little bit..
Learn how to debug things, we tend to help out with things in a smaller area, things this big (and hard to debug) would be recommended to hire somebody.. please take this with a grain of salt
oh I didn't know it was AI written
I just found it from #hackathon
and it looked like it had auth working which is what I needed
and in my local tests auth worked
I essentially needed a starter with better auth
Pretty sure this uses Convex Auth and not Better Auth
I saw useConvextAuth somewhere

Could be massively outdated.
I'm sure it worked, it has way to much issues in prod, this is why i mentioned to debug it locally first
the problem is that this issue only appears in production
locally full flow works
thats why I asked how to debug as I can't get logs
Run npm build
And start fixing what ever causes it to fail
npm build passes
For convex? Let me read the docs
its runtime error
There's no way it runs
@Sara do you have a sec ? I have question about deployments.

or what do you mean
Give me a moment, imma try to run it on my end
are envs i have in prod for ref

it might be I miss some env for convex fn
@Sara can pull, i just pushed a commit to simplify auth to only otp
not that it is relevant to the issue
but i didn't need the other stuff
thank you lots for the help ❤️
I won't be spending more than 20 min on this
yea ofc
you're on your own after that
i really just need a way to get runtime logs somehow
if its convex fn failing

its strange as dash makes it seem like no fn are deployed even
and vercel doesn't show logs too strangely

I've already spotted soooo many problems:
1. tests need to be run in a seperate folder, and not just for "snapshots" or to make sure that a component mounts, because it always mounts 😅
2. the eslint has some bad rules like turning off the any type error, and using a deprecated config,
3. somehow, you've turned off everything that shows you the errors and helps you fix them, and it's causing both local and build to pass, but when you do anything (say interact with pages) you get type errors almost instantly
oo the eslint turn of is super bad indeed
I mentioned it to @Topf
ok i will sort eslint for now
also, Sometimmes it helps to read the error


and to make it make sense, in this case you'd use a link and give it the buttonVariants property
but this issue seems like it happens in convex function?
i think it is checking for session and is failing in production env only
you might not have the enviroment variables for the config defined
its failing immediatly because of it
Custom Domains & Hosting | Convex Developer Hub
Serve requests from any domains and host your frontend on any static hosting provider, such as GitHub.
i set all the envs asked here
also the envs i have in vercel are same ones in localhost (diff values only)
i checked
.env.local*but if you read the .env.example
there's additional env variables that you need to define
or set the default to false
ok yea i see
BETTER_AUTH_SECRET=REPLACE_WITH_32_CHAR_SECRET
ok will set it all up now, thank youyou have other variables too .. if you read the function, you can figure out which ones' you need to set, hint: the github, apple, google, etc ones
ok this makes sense
good luck, I'm heading off to bed now.
read the code before you judge the element
good night and thanks a lot
yea will do
I’d recommend reading the Readme for a start. It’s not overly extensive (I just factored this code out of another project I am using Better Auth for), but it does contain a lot of the information you have been seeking, including the variables: https://github.com/Topfi/BetterAuth-Convex-9ui-shadcn-CLI-/blob/main/README.md
GitHub
BetterAuth-Convex-9ui-shadcn-CLI-/README.md at main · Topfi/Better...
🔐 A polished Better Auth + Convex setup with React 19 & Vite. Full auth flows (magic links, OTP, TOTP, social sign-in), strong security, styled UI, & realtime sync. Perfect for MVPs...
yea I read the readme twice now but it doesn’t say much about resend except that you can set the env for resend and that emails would work in production
i am now writing a helper so that logs happen on the server as that’s the only way vercel can see logs
because it’s unclear to me why resend logic would not activate
i don’t think i changed that part of the flow and left it as is
i only removed magic links to simplify as I just want to have OTP code sending
i also double checked that resend credentials are correct too so issue is not there
that’s for this issue https://discord.com/channels/1019350475847499849/1420203995540095108
the variables issue is solved, apologize for missing parts of the readme at the time
ok I think I know the cause of the bug now but it's unclear to me how the email
from its sending from is chosen, shared more in https://discord.com/channels/1019350475847499849/1420203995540095108/1420304551906381836
ok i solved it i thinkits this env


but it still doesn't send it, I am so confused
thats on new build
What is MAIL_CONSOLE_PREVIEW set to at the moment, if I may ask?
I didn't have it set
but setting it now to
false nowp.s. this is super exciting

I wonder actually if tanstack start will be supported in future, I quite love their typed router
although current setup works well too
ok just set this to
false
i still don't get emails delivered
not in spam too
it's like it never reaches the resend fn send
i think as far as envs go, I should be ok tho
its 200 on the request
mm

What envs are currently set in your Convex deployment?
sec

oo
MAIL_CONSOLE_PREVIEW
i need this in convex too right?Resend is a convex component

ok if i update the env
i can just try auth flow now right?
i don't have to redeploy anything
You need to set the envs that component needs according to: https://www.convex.dev/components/resend
I’d read that and the Better Auth component docs for a start, I used those components. The general Better Auth docs are also helpful for understanding, same with Resend. That should give you a good base for what to adapt for a Vercel prod deploy
My repo is just a simple implementation of those with some niceties like considerations for naming conflicts, passphrase strength check, etc
Resend implementation is as close to vanilla as one can be
thank you
ohh
RESEND_WEBHOOK_SECRET
ok this is missing
but you don't mention it in readme

should I pr the readme?
adding the env for now
Did you read the Convex Resend doc in its entirety and take your time to understand it?
There is no need to set up a Webhook to address any issue you may currently have, that is under advanced because it is optional and not needed for sending mails via resend
im still confused tbh
i read through thing, reading through more code now
i need some kind of
log() fn that can get me logs shown in vercel dashboard
so i can actually debug at what point it fails
as right now its bit strange, there are no errors
it just doesn't send the emailMaybe you are significantly faster than me, but I’d struggle to read and comprehend all that so quickly. If you have an understanding of the official docs, some poor technical writer slaved over, quite a few questions you’ve had become far clearer. Like which vars to keep in your deployment when adapting to Vercel.
As it stands, to me it seems like you missed a bit when doing that.
That way you also have a much better base to rely on when issues arise, can isolate that stuff, etc
for the envs, I 100% double checked now through the list
its not an env issue
i think I may have messed smth up in the logic accidentally
so going through full convex flow from auth
to when it sends the email
and tracing things with logs
otherwise its black box to me kind of
like I have a vague understanding of what happens and i worked with better auth before
but better auth + convex is new to me
And you have read the Better Auth Convex component specific docs as recommended as well?
If so, I’d suggest trying the official example implementation. All I did was make some additions and considerations for real world use on top of that, but maybe that works better for you: https://github.com/get-convex/better-auth/tree/main/examples/react
GitHub
better-auth/examples/react at main · get-convex/better-auth
Convex + Better Auth 🔥. Contribute to get-convex/better-auth development by creating an account on GitHub.