From 6af2106be43a28158da03120cdfa94c0d0463920 Mon Sep 17 00:00:00 2001 From: CSDUMMI Date: Wed, 10 Apr 2024 18:59:59 +0200 Subject: [PATCH] Fix #29770 by only parsing REDIS_PORT and REDIS_DB variable if REDIS_URL is not used. --- streaming/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/streaming/index.js b/streaming/index.js index 154ecbc02c5..5af66e24120 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -241,16 +241,16 @@ const redisConfigFromEnv = (env) => { // which means we can't use it. But this is something that should be looked into. const redisPrefix = env.REDIS_NAMESPACE ? `${env.REDIS_NAMESPACE}:` : ''; - let redisPort = parseIntFromEnv(env.REDIS_PORT, 6379, 'REDIS_PORT'); - let redisDatabase = parseIntFromEnv(env.REDIS_DB, 0, 'REDIS_DB'); + /** @type {import('ioredis').RedisOptions} */ - const redisParams = { + const redisParams = typeof env.REDIS_URL !== 'string' ? { host: env.REDIS_HOST || '127.0.0.1', - port: redisPort, - db: redisDatabase, + port: parseIntFromEnv(env.REDIS_PORT, 6379, 'REDIS_PORT'), + db: parseIntFromEnv(env.REDIS_DB, 0, 'REDIS_DB'), password: env.REDIS_PASSWORD || undefined, - }; + } : {}; + // redisParams.path takes precedence over host and port. if (env.REDIS_URL && env.REDIS_URL.startsWith('unix://')) {