mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-24 08:28:27 +03:00
Release client on error
This commit is contained in:
@@ -36,16 +36,20 @@ export class Postgres implements IDatabase {
|
||||
|
||||
async init(): Promise<void> {
|
||||
this.pool = new Pool(this.config.postgres);
|
||||
this.pool.on("error", (err) => {
|
||||
this.pool.on("error", (err, client) => {
|
||||
Logger.error(err.stack);
|
||||
this.lastPoolFail = Date.now();
|
||||
|
||||
client.release(true);
|
||||
});
|
||||
|
||||
if (this.config.postgresReadOnly) {
|
||||
this.poolRead = new Pool(this.config.postgresReadOnly);
|
||||
this.poolRead.on("error", (err) => {
|
||||
this.poolRead.on("error", (err, client) => {
|
||||
Logger.error(err.stack);
|
||||
this.lastPoolReadFail = Date.now();
|
||||
|
||||
client.release(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user