My whole node app crashes with "Unhandled promise rejection" SequelizeConnectionRefusedError when for some reason (ex. heavy db load) the database rejects the connection.
I want to find a solution so that the app does not crash and if possible try to reconnect.
This is how I connect to the database
const db = new Sequelize(DATABASE_URL, {
logging: false,
pool: {
max: parseInt(NUMBER_PG_CONNECTIONS),
min: 1,
idle: 10000,
acquire: 30000,
},
dialectOptions: {
ssl: {
require: true,
},
},
ssl: true,
});