BetterAuth+Prisma given Too many Connections error
Hey, i've been having an issue with better auth. i tend to get too many connections error
and i normally don't get this before
Versions are "@better-auth/expo": "^1.2.6-beta.8",
and
"better-auth": "1.2.6-beta.6",
Auth.ts
Prisma/db.ts
18 Replies
you should cache the conn like this
this creates a single shared PrismaClient instance to prevent multiple database connections. It stores the instance globally in development to survive hot-reloads while keeping just one connection in production.
ok would try and let you know
hey @KiNFiSH . i've the change. when i try signing in to my app an error occurs ``````
can you do the generation and push once again
can u send me schema.prisma file ?
i want to see where the generated config are actually stored ?
ok
on it
they are stored at "./generated/prisma"
so you should update your prisma client import like
i mean prisma should be right from where you generate the client
oh
but there's no "prisma" coming from the grenerated file
just Prisma and PrismaClient
so you that to create a client
i did that a while back but was worried it would create multiple connections
wait lemme batch thme up
no prisma cleint is updted with in the db
instead of creating a client on the auth config
now pass the db to the adapter as you were doing
that's what i did. in my db.ts
This is my imports
Then
but now you cache the connection thats why the global is introduced
make sure to use the generrated client to create prisma client.
ok let me send my full db.ts. as well as my auth.ts
error
where is db import ? in auth config
sorry. my bad. i was putting and not
that error has gone
silly me
i would update you further if i still get "too many connections error"
Thank you for your assistance