CRITICAL BUG IN PRODUCTION: authClient.useSession returns the session of a random user
I used authClient.useSession in the development environment, everything is working perfectly fine. When I tried to use it in production, it gets the session of a random user all of the time even if I log out & sign in again, it gets that random user.
I "solved" this issue by getting the session on the server for now....
10 Replies
Are you able to consistently get this issue? Are you able to create a repro?
auth.ts:
auth-client.ts:
logout-dialog.tsx (where the bug occurs)
When I use this component, the session it gets is another user's session. I tried checking networking & the problem comes from /api/auth/get-session endpoint where the session of the other user (Not the current) is shown
what version are you in? also is there anyway you can send us something we can reproduce on our end?
I'm in version 1.2.7
What's the other way? Could you please tell me how you can reproduce other than having the auth instance & the client?
The problem happened when a new user signed up (with google credentials), the data from /api/auth/get-session becomes the data of that user.
The problem happens ONLY when using authClient.useSession(), when I tried getting the session from the server (i.e: auth.api.getSession()), it got fixed.
I tried to log out/log in again from my account but still the returned value is the session of the last signed up user
Reproduce as in a temporary repo implementing the issue you're encountering so that we can debug further
We couldn't reproduce the issue in our end, with the same setup. It'd be easier for us to look at, if you can give us a minimal repo we can take a look to see the issue happening.
Sure I'll do that ASAP.
could you please try signing in with an account.
Then in other browser try signing up with google credentials account (the bug happened twice this way, when 2 users signed up with google)
@Maqed production was deployed to vercel?
Netlify
wondering if you were logging like via sentry or analytics any session (not just better-auth) details in the hosting runtime.
i remember vercel had a hot bug that was related to nextjs header issues but that was a while ago and you're not use vercel
i would verify that by cramming in a debug session id initiated from the client side and then see if you randomly get the issue if its the same session back when its happening
is it consisten?