Error Too many connections with Drizzle + MySQL2
I have my DB setup as follow:
I keep getting the error
Too many connections
after refreshing the page several times. How can I fix it?10 Replies
it’s a problem with hot reload in NextJS. Try using singleton for your connection pool.
do you have any examples?
Here is what I meant, you check if there is any existing drizzle instance before creating one.
Where does „globalThis“ comes from and would that also work in edge functions? Serverless functions?
this is my way for avoiding connection exhaustion in HMR
afaik it wont work on serverless which is why serverless drivers and the drizzle http proxy exists, but i dont get enough traffic per second to exhaust connections
that's also a good way to prevent multiple sessions. I just set the limit to unlimited, because there is also not that much traffic and then close them automatically via this: https://stackoverflow.com/questions/12391174/how-to-close-idle-connections-in-postgresql-automatically/69528572#69528572
Stack Overflow
How to close idle connections in PostgreSQL automatically?
Some clients connect to our postgresql database but leave the connections opened.
Is it possible to tell Postgresql to close those connection after a certain amount of inactivity ?
TL;DR
IF you're...
i should probably check what mine is set to, presumably the default
but what's the default? xD
0/disabled I believe
haven’t encountered any errors so im probably fine for now
oh xD
I think I end idling connections after like 15 minutes. I guess that's a good number. Or maybe even 5 minutes..