From 9d71e34a833b68eceb788a0bc55cd87936bde816 Mon Sep 17 00:00:00 2001 From: Kenneth Foster Date: Thu, 8 Jun 2023 17:48:18 -0400 Subject: [PATCH 1/6] [empty commit] pull request for fixing redis auth From f68452c47a32bd9d9c12307e594ee6c1e367f37e Mon Sep 17 00:00:00 2001 From: Kenneth Foster Date: Fri, 9 Jun 2023 14:54:17 -0400 Subject: [PATCH 2/6] Added changes to stop auth attempts after an error --- server/util-server.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index daf98de62..a332764c6 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -413,22 +413,25 @@ exports.radius = function ( exports.redisPingAsync = function (dsn) { return new Promise((resolve, reject) => { const client = redis.createClient({ - url: dsn, + url: dsn }); client.on("error", (err) => { + client.disconnect(); reject(err); }); client.connect().then(() => { - client.ping().then((res, err) => { - if (client.isOpen) { - client.disconnect(); - } - if (err) { - reject(err); - } else { - resolve(res); - } - }); + if(client.isOpen){ + client.ping().then((res, err) => { + if (client.isOpen) { + client.disconnect(); + } + if (err) { + reject(err); + } else { + resolve(res); + } + }); + } }); }); }; From 6132a45c7c9a97153bfd03a7e20528cc249ec0c3 Mon Sep 17 00:00:00 2001 From: Kenneth Foster Date: Fri, 9 Jun 2023 16:06:33 -0400 Subject: [PATCH 3/6] fixed when auth is needed but not provided --- server/util-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util-server.js b/server/util-server.js index a332764c6..69149e589 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -430,7 +430,7 @@ exports.redisPingAsync = function (dsn) { } else { resolve(res); } - }); + }).catch(error => reject(error)); } }); }); From 88973856908f2f9797acb3b0d681d9e29f618a1f Mon Sep 17 00:00:00 2001 From: Kenneth Foster Date: Fri, 9 Jun 2023 16:26:02 -0400 Subject: [PATCH 4/6] Fixed linting --- server/util-server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index 69149e589..667d5dc68 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -420,7 +420,7 @@ exports.redisPingAsync = function (dsn) { reject(err); }); client.connect().then(() => { - if(client.isOpen){ + if (client.isOpen) { client.ping().then((res, err) => { if (client.isOpen) { client.disconnect(); @@ -430,8 +430,8 @@ exports.redisPingAsync = function (dsn) { } else { resolve(res); } - }).catch(error => reject(error)); - } + }).catch(error => reject); + } }); }); }; From d37c33ad42f994137c0a989cb4b7f9a1f16906c2 Mon Sep 17 00:00:00 2001 From: kefoster951 <42386206+kefoster951@users.noreply.github.com> Date: Mon, 12 Jun 2023 11:06:20 -0400 Subject: [PATCH 5/6] Update server/util-server.js Co-authored-by: Frank Elsinga --- server/util-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util-server.js b/server/util-server.js index 667d5dc68..0cf959596 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -416,7 +416,7 @@ exports.redisPingAsync = function (dsn) { url: dsn }); client.on("error", (err) => { - client.disconnect(); + if (client.isOpen) client.disconnect(); reject(err); }); client.connect().then(() => { From 6708eed1219a7b806f1e3a43d75d72e0b070c24e Mon Sep 17 00:00:00 2001 From: Kenneth Foster Date: Wed, 14 Jun 2023 11:49:33 -0400 Subject: [PATCH 6/6] Fixed error handling if client is closed --- server/util-server.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index 0cf959596..3c382b714 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -416,22 +416,25 @@ exports.redisPingAsync = function (dsn) { url: dsn }); client.on("error", (err) => { - if (client.isOpen) client.disconnect(); + if (client.isOpen) { + client.disconnect(); + } reject(err); }); client.connect().then(() => { - if (client.isOpen) { - client.ping().then((res, err) => { - if (client.isOpen) { - client.disconnect(); - } - if (err) { - reject(err); - } else { - resolve(res); - } - }).catch(error => reject); + if (!client.isOpen) { + client.emit("error", new Error("connection isn't open")); } + client.ping().then((res, err) => { + if (client.isOpen) { + client.disconnect(); + } + if (err) { + reject(err); + } else { + resolve(res); + } + }).catch(error => reject(error)); }); }); };