1
0
Fork 0

Add activeRequests info on db acquire timeout

Can help us to debug sequelize acquire timeout error
This commit is contained in:
Chocobozzz 2022-09-08 10:18:38 +02:00
parent 5b7e3f276d
commit 37a04703a4
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -258,9 +258,16 @@ app.use((err, _req, res: express.Response, _next) => {
if (err) { if (err) {
error = err.stack || err.message || err error = err.stack || err.message || err
} }
// Handling Sequelize error traces // Handling Sequelize error traces
const sql = err.parent ? err.parent.sql : undefined const sql = err?.parent ? err.parent.sql : undefined
logger.error('Error in controller.', { err: error, sql })
// Help us to debug SequelizeConnectionAcquireTimeoutError errors
const activeRequests = err?.name === 'SequelizeConnectionAcquireTimeoutError' && typeof (process as any)._getActiveRequests !== 'function'
? (process as any)._getActiveRequests()
: undefined
logger.error('Error in controller.', { err: error, sql, activeRequests })
return res.fail({ return res.fail({
status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500, status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500,