diff --git a/src/databases/Postgres.ts b/src/databases/Postgres.ts index 161a9c9..db72021 100644 --- a/src/databases/Postgres.ts +++ b/src/databases/Postgres.ts @@ -53,19 +53,23 @@ export class Postgres implements IDatabase { }); if (this.config.postgresReadOnly && this.config.postgresReadOnly.enabled) { - this.poolRead = new Pool({ - ...this.config.postgresReadOnly - }); - this.poolRead.on("error", (err, client) => { - Logger.error(err.stack); - this.lastPoolReadFail = Date.now(); + try { + this.poolRead = new Pool({ + ...this.config.postgresReadOnly + }); + this.poolRead.on("error", (err, client) => { + Logger.error(err.stack); + this.lastPoolReadFail = Date.now(); - try { - client.release(true); - } catch (err) { - Logger.error(`poolRead (postgres): ${err}`); - } - }); + try { + client.release(true); + } catch (err) { + Logger.error(`poolRead (postgres): ${err}`); + } + }); + } catch (e) { + Logger.error(`poolRead (postgres): ${e}`); + } } if (!this.config.readOnly) {