From 1b6c5b8f97a0666e2cee25624f1da61349e15a76 Mon Sep 17 00:00:00 2001 From: timvisee Date: Tue, 20 Apr 2021 18:37:19 +0200 Subject: [PATCH] Only set Redis client password if password is specified This attempts to fix a Redis connection issue when the Redis password is an empty string. See https://github.com/timvisee/send-docker-compose/issues/3#issuecomment-822885578 --- server/storage/redis.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/storage/redis.js b/server/storage/redis.js index 6a21391f..3d74d01f 100644 --- a/server/storage/redis.js +++ b/server/storage/redis.js @@ -8,10 +8,10 @@ module.exports = function(config) { //eslint-disable-next-line security/detect-non-literal-require const redis = require(redis_lib); - const client = redis.createClient({ + + var client_config = { host: config.redis_host, port: config.redis_port, - password: config.redis_password, retry_strategy: options => { if (options.total_retry_time > config.redis_retry_time) { client.emit('error', 'Retry time exhausted'); @@ -20,7 +20,10 @@ module.exports = function(config) { return config.redis_retry_delay; } - }); + }; + if (config.redis_password != null && config.redis_password.length > 0) + client_config.password = config.redis_password; + const client = redis.createClient(client_config); client.ttlAsync = promisify(client.ttl); client.hgetallAsync = promisify(client.hgetall);