Skip to content

Commit

Permalink
Add the ability to specify query/statement timeouts for pg backend
Browse files Browse the repository at this point in the history
Change-type: minor
  • Loading branch information
Page- committed Jan 22, 2021
1 parent 12e01a7 commit 59e6548
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/config-loader/env.ts
Original file line number Diff line number Diff line change
@@ -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,
};
2 changes: 2 additions & 0 deletions src/database-layer/db.ts
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 59e6548

Please sign in to comment.