how can I handle error event in connect-redis? #11

Closed
vlapan opened this Issue Jan 2, 2011 · 4 comments

3 participants

@vlapan

how can I handle error event in connect-redis?
from node-redis readme:
"client will emit error when encountering an error connecting to the Redis server. Note that "error" is a special event type in node. If there are no listeners for an "error" event, node will exit."

@tj
Owner
tj commented Jan 2, 2011

if you named the instance "store":
store.client.on('error', function(err){});

@vlapan

thanks!

@ghost

If I am trying to capture an event within my express app when a different redis server (which is the current session store) becomes unreachable for any reason. I've tried store.client.on('error', function(err){}); but store is undefined.
I have
app.use(express.session({secret: 'keyboardcat',store: new RedisStore({}));
I tried app.store.on("error", function(err){}); can I get cannot call method on.

@bushev

Some errors still not handled by: client.on('error', function(err){});

Ex:

var redis = require('redis');
var redisClient = redis.createClient(port, host);

redisClient.on('connect', function(){
    console.log('Connected to Redis');
});

redisClient.on('error', function(err) {
     console.log('Redis error: ' + err);
});

app.use(session({
    store: new RedisStore({
        client: redisClient
    }),
    secret: '***',
    resave: false,
    saveUninitialized: true,
    cookie: {
        secure: false
    },
    name: '***' + app.get('env')
}));

Cause:

[11:48:37.809] [LOG] Error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
    at Error (native)
    at HiredisReplyParser.execute (/Users/bushev/IdeaProjects/org/app/node_modules/redis/lib/parser/hiredis.js:30:33)
    at RedisClient.on_data (/Users/bushev/IdeaProjects/org/app/node_modules/redis/index.js:549:27)
    at Socket.<anonymous> (/Users/bushev/IdeaProjects/org/app/node_modules/redis/index.js:102:14)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at TCP.onread (net.js:523:20)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment