From 37a04703a4b9829cb9aef6c5bb8835d2fa2f2fbc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Sep 2022 10:18:38 +0200 Subject: [PATCH] Add activeRequests info on db acquire timeout Can help us to debug sequelize acquire timeout error --- server.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 6073d2ea4..63a08f471 100644 --- a/server.ts +++ b/server.ts @@ -258,9 +258,16 @@ app.use((err, _req, res: express.Response, _next) => { if (err) { error = err.stack || err.message || err } + // Handling Sequelize error traces - const sql = err.parent ? err.parent.sql : undefined - logger.error('Error in controller.', { err: error, sql }) + const sql = err?.parent ? err.parent.sql : undefined + + // 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({ status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500,