You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running an app using express-session, but getting req.session is undefined when certain users try to access the server after a restart where we changed the session key. (FWIW this is the real bug we're trying to solve, and have eve implemented the suggestion from #99, but this issue isn't for that bug).
Right now I've got:
DEBUG=express-session:* node server.js
Right before I attach the session middleware:
if (process.env.DEBUG) {
console.log('DEBUG is set to', process.env.DEBUG);
}
var sessionMiddleware = session({
store: sessionStore, // we are using connect-redis for now
key: 'express_sid',
secret: 'ABIGSECRET',
resave: true,
saveUninitialized: true,
unset: 'destroy'
});
args.app.use(function (req, res, next) {
var attempt = 0;
function lookupSession(err) {
if (err) {
log.fatal('Error in session middleware', {err: err, req: req});
return next(err);
}
++attempt;
if (req.session !== undefined) {
return next();
}
if (attempt > maxAttempts) {
log.fatal('unable to generate sessions, max attempts exhausted');
return next(new Error('Unable to generate session'));
}
sessionMiddleware(req, res, lookupSession);
}
lookupSession();
});
I see the following output when I start the server: DEBUG is set to express-session:*
But I see no debug output whenever any of my clients hit the server. Any help is appreciated.
The text was updated successfully, but these errors were encountered:
It's also important to note that your session store, connect-redis it seems, is what controls when the value of req.session will be undefined or not; this module is really just the management system for those stores. I'm just saying this because even if you start your server with the proper DEBUG=express-session node server.js, I'm not sure how much it's output will help.
Actually, nevermind. You should see lots of store is disconnected in your output, which indicates that connect-redis is telling us not to ask it for sessions right now.
Ah! That explains it. I thought you always needed to pass in a "component filter" for debug, or at least tell it not to filter the output at all.
Yeah, we're really scratching our heads with this one -- only SOME sessions are unable to do this, some work file. And we're using the same redis instance for our socket.io server, so we know it's there. (Although we are prepping to switch to the level one I wrote since we're a single node instance and don't really need redis here).
Running an app using express-session, but getting
req.session
is undefined when certain users try to access the server after a restart where we changed the session key. (FWIW this is the real bug we're trying to solve, and have eve implemented the suggestion from #99, but this issue isn't for that bug).Right now I've got:
DEBUG=express-session:* node server.js
Right before I attach the session middleware:
I see the following output when I start the server:
DEBUG is set to express-session:*
But I see no debug output whenever any of my clients hit the server. Any help is appreciated.
The text was updated successfully, but these errors were encountered: