Open steveliles opened 10 years ago
Mongo session expiry uses a TTL index. The index is created by this code in index.js:
var schema = new mongoose.Schema({ sid: { type: String, required: true, unique: true }, data: { type: {} }, lastAccess: { type: Date, index: { expires: parseInt(options.expire) * 1000 } }, expires: { type: Date, index: true } });
The issue here is that expires is set to options.expire*1000, as if expecting to receive a value in seconds and convert it to milliseconds. However, if we look at the index that gets created:
expires
{ "v" : 1, "name" : "lastAccess_1", "key" : { "lastAccess" : 1 }, "ns" : "mayqat.sessions", "expireAfterSeconds" : 60000, "background" : true, "safe" : null }
Notice that mongodb actually calls the value "expireAfterSeconds".
Easy fix: don't multiply by 1000 :)
I have forked and fixed, and could provide a pull request, though i've changed one other thing also (for issue 3).
Mongo session expiry uses a TTL index. The index is created by this code in index.js:
The issue here is that
expires
is set to options.expire*1000, as if expecting to receive a value in seconds and convert it to milliseconds. However, if we look at the index that gets created:Notice that mongodb actually calls the value "expireAfterSeconds".
Easy fix: don't multiply by 1000 :)
I have forked and fixed, and could provide a pull request, though i've changed one other thing also (for issue 3).