-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG][Supabase][Postgres client] Exhausted connection pool #928
Comments
Hello, @atanaskanchev! I was wondering if you had already solved this issue since I myself have been struggling with it for quite some time, and it is getting more frequent right now. I would love to hear from you if you have any workarounds for this. |
I'm experiencing the same problem |
same here too |
In my case, this issue arises due to hot reloading during development. With each hot reload, a new Drizzle instance is created, consuming a new connection. Here's my code, which I adapted from the Prisma version. import { drizzle } from "drizzle-orm/postgres-js"
import postgres from "postgres"
declare module global {
let postgresSqlClient: ReturnType<typeof postgres> | undefined
}
let postgresSqlClient
const databaseUrl = 'postgres://postgres:adminadmin@0.0.0.0:5432/db'
if (process.env.NODE_ENV !== "production") {
if (!global.postgresSqlClient) {
global.postgresSqlClient = postgres(databaseUrl)
}
postgresSqlClient = global.postgresSqlClient
} else {
postgresSqlClient = postgres(databaseUrl)
}
export const db = drizzle(postgresSqlClient) Reference |
This is know issue if you're using HMR. The solution is given in the comment above. |
What version of
drizzle-orm
are you using?0.27.2
What version of
drizzle-kit
are you using?0.19.10
Describe the Bug
Expected behavior
No response
Environment & setup
Client setup
The text was updated successfully, but these errors were encountered: