0

connect-redis is throwing the below error after upgrading to v7. The code works perfectly fine in v6.x.x . Can you please suggest what needs to be modified or what I am missing here? Couldn't exactly find details on what has suddenly changed in v7 to break this code.

Error : "message":"Failed to connect to redis: TypeError: RedisConnect is not a function"}

Code Snippet :

const Redis = require('ioredis');
const expressSession = require('express-session');
const RedisConnect = require('connect-redis');

createRedisStore(client) {
this.config.logger.debug('Initializing redis session store');
const redisOptions = {
client,
ttl: this.config.redisSessionTTL,
prefix: this.config.redisSessionPrefix,
pass: this.config.usePassword === true,
};

    this.config.logger.error(`Created session store config;     ${this.config.redisSessionServerAddress}:${
  this.config.redisSessionServerPort
}`);
    
    const RedisStore = RedisConnect(expressSession);

    let store = null;

    this.config.logger.error('Created redis object');
    try {
      store = new RedisStore(redisOptions);
    } catch (err) {
      this.config.logger.fatal(`Redis store error: ${err}`);
      return Promise.reject(err);
    }

    return Promise.resolve(store);

}`

Tried different variations and researching and everyone is suggesting to pass the session object into the connect redis object which is throwing an error now for some reason.

0 Answers0