Prevent errors from double calling release

This commit is contained in:
Ajay 2022-06-30 01:37:50 -04:00
parent de60415f55
commit b1b40d410f

View file

@ -40,7 +40,11 @@ export class Postgres implements IDatabase {
Logger.error(err.stack);
this.lastPoolFail = Date.now();
try {
client.release(true);
} catch (err) {
Logger.error(`prepare (postgres): ${err}`);
}
});
if (this.config.postgresReadOnly) {
@ -49,7 +53,11 @@ export class Postgres implements IDatabase {
Logger.error(err.stack);
this.lastPoolReadFail = Date.now();
try {
client.release(true);
} catch (err) {
Logger.error(`prepare (postgres): ${err}`);
}
});
}
@ -109,7 +117,11 @@ export class Postgres implements IDatabase {
} catch (err) {
Logger.error(`prepare (postgres): ${err}`);
} finally {
try {
client?.release();
} catch (err) {
Logger.error(`prepare (postgres): ${err}`);
}
}
}