PrismaP
Prisma2y ago
13 replies
LuCrypto

Prisma too many connection to my database

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
Was this page helpful?