-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
According to https://github.com/prisma/prisma-client-js/issues/228#issuecomment-618433162, we must use the below code in next.js environments to prevent the too many connections error.
import { PrismaClient } from "@prisma/client"
export * from "@prisma/client"
let prisma: PrismaClient
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient()
} else {
// Ensure the prisma instance is re-used during hot-reloading
// Otherwise, a new client will be created on every reload
globalThis["prisma"] = globalThis["prisma"] || new PrismaClient()
prisma = globalThis["prisma"]
}
export default prismaRight now with that code this plugin is worthless, because prisma doesn't get reinstantiated.
Proposal
On prisma schema change, in addition to clearing the require cache, also delete global.prisma and globalThis.prisma
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels