2

I am setting up redis with express-session in node.

I am getting this error:

if (options.unref) this.client.unref();
this.client.unref is not a function

this error points to redis-connect's library in my node_modules.

here's the basic code I have in node:

var express = require('express');
var session = require('express-session');
var redis = require('redis');
var redisStore = require('connect-redis')(session);

then,

var client = redis.createClient();
var sessionStore = new redisStore(client);

app.use(session({
  store: sessionStore,
  secret: 'a stringy string thing',
}))

how do I address the error? thanks!

theman0123
  • 153
  • 1
  • 17

1 Answers1

3

The correct way of creating the Redis store instance:

var sessionStore = new redisStore({ client : client });

In other words, redisStore requires an options object to be passed as argument, and not the Redis client instance directly.

robertklep
  • 198,204
  • 35
  • 394
  • 381