-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fails when i use connect-mongodb to store the session #4
Comments
I have the exact same problem when using Redis as a session store. |
I had the same issue and upon further inspection it appears that adding a process.nextTick to RedisStore gets it working if you use the domain middleware first. The MemoryStore session store for express includes the process.nextTick, but RedisStore didn't. When I add the session middleware, if I do it like this, it will work with domains:
I'm not sure why, I guess it has something to do with how domains work though. |
The problem is, this module calls As a solution, I've wrapped dispose in var domain = require('domain');
...
app.use(function(req, res, next) {
var d = domain.create();
function dispose() {
//let dust settle
process.nextTick(d.dispose.bind(d));
}
res.on('close', dispose);
res.on('finish', dispose);
d.on('error', function (err) {
dispose();
next(err);
});
d.run(next);
}); Will create a new module soon... |
Beware, asynchronous jobs related to the request will get closed after a tick, so if they last longer than that, they will get silently cancelled. This is good and bad, good because it clears up callbacks related to a crash, though bad if you're wanting to do something in after the request, like logging. |
This is a so convoluted error that took me a while to discover.. It is an specific combination of modules (request and connect-mongodb).
Here is the smallest version I did:
The text was updated successfully, but these errors were encountered: