From 33bbc0e7e6be370c944e979a34ab2cb19562d1e3 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Tue, 30 Apr 2024 18:06:11 +0200 Subject: [PATCH] fix(PostgreSQL): better handle connection errors, should fix #794 --- src/main/libs/clients/PostgreSQLClient.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/libs/clients/PostgreSQLClient.ts b/src/main/libs/clients/PostgreSQLClient.ts index 5b192b04..af20f8d6 100644 --- a/src/main/libs/clients/PostgreSQLClient.ts +++ b/src/main/libs/clients/PostgreSQLClient.ts @@ -210,6 +210,10 @@ export class PostgreSQLClient extends BaseClient { if (this._params.readonly) await connection.query('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY'); + connection.on('error', err => { // Intercepts errors and converts to rejections + Promise.reject(err); + }); + return connection; }