From 9c1cdaee7976673c603550050a5243d6d6a342ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 13 May 2020 12:23:21 +0200 Subject: [PATCH] Log always on error --- index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 5df69d7..fc184fb 100644 --- a/index.js +++ b/index.js @@ -141,16 +141,19 @@ function makePool (redisPool, database) { }); client.on('error', (err) => { - if (!settled) { - settled = true; - client.end(FLUSH_CONNECTION); + if (settled) { + err.name = redisPool.options.name; + return redisPool.logger.error(err); + } - if (err) { - return resolve(err); - } + settled = true; + client.end(FLUSH_CONNECTION); - return resolve(client); + if (err) { + return resolve(err); } + + return resolve(client); }); client.on('ready', () => { @@ -161,6 +164,7 @@ function makePool (redisPool, database) { if (err) { return resolve(err); } + return resolve(client); } });