nikiv.dev
nikiv.dev2mo ago

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?
No description
85 Replies
nikiv.dev
nikiv.devOP2mo ago
this only happens in production
Slimy
Slimy2mo ago
I think you imported an Convex server function into the client
nikiv.dev
nikiv.devOP2mo ago
nikiv.dev
nikiv.devOP2mo ago
nikiv.dev
nikiv.devOP2mo ago
interesting, can you help understand where I can import it https://github.com/genxai/new im checking sign-in route now
Slimy
Slimy2mo ago
Can'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.
nikiv.dev
nikiv.devOP2mo ago
is there env responsible for server fn in convex mby i missed adding it in vercel but I think I added everything
nikiv.dev
nikiv.devOP2mo ago
oh this doc I read, I think I got all envs from there
nikiv.dev
nikiv.devOP2mo ago
ok i think that maybe the cause as I do use custom domain
No description
nikiv.dev
nikiv.devOP2mo ago
checking it more now only thing its unclear what CONVEX_CLOUD_URL should be
Sara
Sara2mo ago
Hi, 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
nikiv.dev
nikiv.devOP2mo ago
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
Slimy
Slimy2mo ago
Pretty sure this uses Convex Auth and not Better Auth I saw useConvextAuth somewhere
nikiv.dev
nikiv.devOP2mo ago
No description
Slimy
Slimy2mo ago
Could be massively outdated.
Sara
Sara2mo ago
I'm sure it worked, it has way to much issues in prod, this is why i mentioned to debug it locally first
nikiv.dev
nikiv.devOP2mo ago
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
Sara
Sara2mo ago
Run npm build And start fixing what ever causes it to fail
nikiv.dev
nikiv.devOP2mo ago
npm build passes
Sara
Sara2mo ago
For convex? Let me read the docs
nikiv.dev
nikiv.devOP2mo ago
its runtime error
Sara
Sara2mo ago
There's no way it runs
Slimy
Slimy2mo ago
@Sara do you have a sec ? I have question about deployments.
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
or what do you mean
Sara
Sara2mo ago
Give me a moment, imma try to run it on my end
nikiv.dev
nikiv.devOP2mo ago
are envs i have in prod for ref
No description
nikiv.dev
nikiv.devOP2mo ago
it might be I miss some env for convex fn
nikiv.dev
nikiv.devOP2mo ago
@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 ❤️
Sara
Sara2mo ago
I won't be spending more than 20 min on this
nikiv.dev
nikiv.devOP2mo ago
yea ofc
Sara
Sara2mo ago
you're on your own after that
nikiv.dev
nikiv.devOP2mo ago
i really just need a way to get runtime logs somehow if its convex fn failing
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
its strange as dash makes it seem like no fn are deployed even
nikiv.dev
nikiv.devOP2mo ago
and vercel doesn't show logs too strangely
No description
Sara
Sara2mo ago
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
nikiv.dev
nikiv.devOP2mo ago
oo the eslint turn of is super bad indeed I mentioned it to @Topf ok i will sort eslint for now
Sara
Sara2mo ago
also, Sometimmes it helps to read the error
No description
nikiv.dev
nikiv.devOP2mo ago
No description
Sara
Sara2mo ago
and to make it make sense, in this case you'd use a link and give it the buttonVariants property
nikiv.dev
nikiv.devOP2mo ago
but this issue seems like it happens in convex function? i think it is checking for session and is failing in production env only
Sara
Sara2mo ago
you might not have the enviroment variables for the config defined its failing immediatly because of it
nikiv.dev
nikiv.devOP2mo ago
Custom Domains & Hosting | Convex Developer Hub
Serve requests from any domains and host your frontend on any static hosting provider, such as GitHub.
nikiv.dev
nikiv.devOP2mo ago
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*
Sara
Sara2mo ago
but if you read the .env.example there's additional env variables that you need to define or set the default to false
nikiv.dev
nikiv.devOP2mo ago
ok yea i see BETTER_AUTH_SECRET=REPLACE_WITH_32_CHAR_SECRET ok will set it all up now, thank you
Sara
Sara2mo ago
you 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
nikiv.dev
nikiv.devOP2mo ago
ok this makes sense
Sara
Sara2mo ago
good luck, I'm heading off to bed now. read the code before you judge the element
nikiv.dev
nikiv.devOP2mo ago
good night and thanks a lot yea will do
Topf
Topf2mo ago
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...
nikiv.dev
nikiv.devOP2mo ago
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 think
nikiv.dev
nikiv.devOP2mo ago
its this env
No description
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
but it still doesn't send it, I am so confused thats on new build
Topf
Topf2mo ago
What is MAIL_CONSOLE_PREVIEW set to at the moment, if I may ask?
nikiv.dev
nikiv.devOP2mo ago
I didn't have it set but setting it now to false now
nikiv.dev
nikiv.devOP2mo ago
p.s. this is super exciting
No description
nikiv.dev
nikiv.devOP2mo ago
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
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
its 200 on the request mm
nikiv.dev
nikiv.devOP2mo ago
No description
Topf
Topf2mo ago
What envs are currently set in your Convex deployment?
nikiv.dev
nikiv.devOP2mo ago
sec
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
oo MAIL_CONSOLE_PREVIEW i need this in convex too right?
Topf
Topf2mo ago
Resend is a convex component
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
ok if i update the env i can just try auth flow now right? i don't have to redeploy anything
Topf
Topf2mo ago
You need to set the envs that component needs according to: https://www.convex.dev/components/resend
Convex
Resend
Send reliable transactional emails to your users with Resend.
Topf
Topf2mo ago
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
nikiv.dev
nikiv.devOP2mo ago
thank you ohh RESEND_WEBHOOK_SECRET ok this is missing
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
but you don't mention it in readme
nikiv.dev
nikiv.devOP2mo ago
No description
nikiv.dev
nikiv.devOP2mo ago
should I pr the readme? adding the env for now
Topf
Topf2mo ago
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
nikiv.dev
nikiv.devOP2mo ago
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 email
Topf
Topf2mo ago
Maybe 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
nikiv.dev
nikiv.devOP2mo ago
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
Topf
Topf2mo ago
And you have read the Better Auth Convex component specific docs as recommended as well?
Topf
Topf2mo ago
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.

Did you find this page helpful?