'Sequelize + postgres max connections error and react hot reload
During development I'm getting the sequelize fatal error code 53300 quite often. After reading about I found out it indicates too many connections from the same client.
In my case this could true, I do instantiate one sequelize client that could potentially do many connections, but to be honest I have no idea how exactly this is happening.
My stack is react with nextjs and sequelize connecting to a heroku postgres DB. I do not manually deal with connection open/close, I'm letting sequelize do that for me.
My sequelize config is set to:
pool: {
max: 10,
min: 1,
acquire: 30000,
idle: 5000,
evict: 1000,
}
What I don't understand is, if sequelize is able to open/close connections for me, why am I getting that error then.
I'm solving the error by stopping the development server on my terminal and starting it again, solves the problem immediately for a while, then it comes back.
Can anyone help me to debug this problem? Should I try to inspect if the DB instance has connections open to my clients? This DB is hosted by heroku and I'm not exactly and admin etc...
Does the config above looks like something that makes sense for a typical web app?
Could it be possible that the hot reload from react is the one creating new connections every time it reloads things after I save my files (which happens hundreds of times in a day)? If so, am I guaranteed to not have this issue on production?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
