From 59e65485c4c7bc40c449b19cfabe4d1148352b92 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Fri, 22 Jan 2021 14:07:53 +0000 Subject: [PATCH] Add the ability to specify query/statement timeouts for pg backend Change-type: minor --- src/config-loader/env.ts | 8 +++++--- src/database-layer/db.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config-loader/env.ts b/src/config-loader/env.ts index ce078f504..da870677a 100644 --- a/src/config-loader/env.ts +++ b/src/config-loader/env.ts @@ -32,9 +32,11 @@ if (process.env.TRANSACTION_TIMEOUT_MS) { export const db = { poolSize: 50, - idleTimeoutMillis: 30000, - connectionTimeoutMillis: 30000, - keepAlive: true, + idleTimeoutMillis: 30000 as number | undefined, + statementTimeout: undefined as number | undefined, + queryTimeout: undefined as number | undefined, + connectionTimeoutMillis: 30000 as number | undefined, + keepAlive: true as boolean | undefined, rollbackTimeout: 30000, timeoutMS, }; diff --git a/src/database-layer/db.ts b/src/database-layer/db.ts index f1cc82a80..616a21200 100644 --- a/src/database-layer/db.ts +++ b/src/database-layer/db.ts @@ -417,6 +417,8 @@ if (maybePg != null) { } config.max = env.db.poolSize; config.idleTimeoutMillis = env.db.idleTimeoutMillis; + config.statement_timeout = env.db.statementTimeout; + config.query_timeout = env.db.queryTimeout; config.connectionTimeoutMillis = env.db.connectionTimeoutMillis; config.keepAlive = env.db.keepAlive; const pool = new pg.Pool(config);