Hey everyone,
I use Prisma for ORM and Neon for my database
I noticed something, my connections aren't unique and after some time, i reach to the max to my database
But i throught i'd solved the problem by doing this :
I have this file and i only imported prisma from this file in my project
prisma.ts
import { PrismaClient } from '@prisma/client'
const prismaClientSingleton = () => {
return new PrismaClient()
}
declare global {
var prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>
}
export const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
Why do I have so many connections?
Thanks in advance for your help