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