Add timeout for all postgres requests

This commit is contained in:
Ajay
2022-11-15 14:19:15 -05:00
parent 4139bf8f8c
commit 9e2e1343da
3 changed files with 4 additions and 1 deletions

View File

@@ -125,6 +125,7 @@ export class Postgres implements IDatabase {
pendingQueries.push(savePromiseState(lastPool.query({ text: query, values: params })));
const currentPromises = [...pendingQueries];
if (options.useReplica && maxTries() - tries > 1) currentPromises.push(savePromiseState(timeoutPomise(this.config.postgresReadOnly.readTimeout)));
else if (this.config.postgres.timeout) currentPromises.push(savePromiseState(timeoutPomise(this.config.postgres.timeout)));
const queryResult = await nextFulfilment(currentPromises);
this.activePostgresRequests--;