hey all, i found a tutorial for nextjs and set up ...
# orm-help
j
hey all, i found a tutorial for nextjs and set up my prisma client like so:
Copy code
import { PrismaClient } from "@prisma/client";

interface CustomNodeJsGlobal {
  prisma: PrismaClient;
}

declare const global: CustomNodeJsGlobal;

const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV === "development") global.prisma = prisma;

export default prisma;
after 10-15 mins of development i keep getting this error:
Copy code
Error querying the database: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
    at cb (/Users/joshua/Desktop/next-prisma/node_modules/@prisma/client/runtime/index.js:36946:17)
my DB is set up on digital ocean and my DB URL looks like this:
Copy code
<postgresql://USER_NAME:PASSWORD@HOST>:PORT/DATABASE?sslmode=require
any tips on how i can eliviate this?
r
Never seen this message before. @janpio do you have any idea?
j
It means all your connections of your Postgres instance are in use.
Probably next is creating new instances all the time, all creating a new connection without closing the old one.
A simple way to fix this will just be to close all open connections to the database manually with a superuser account.
Most database GUIs can do that.
r
But this shouldn’t ideally happen as he’s using the workaround we specified in the docs.
j
restarting
yarn dev
for nextjs seems to help for the 10-15 mins i am able to develop. i will look into closing connections with a superuser
j
Somehow your
yarn dev
is not reusing or closing the connections as it should. If you have a reproduction, might be worth creating an issue.