Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve the session reaping logic.

 * allow validate to return a promise before calling again
 * change sign of timeout length so that it makes sense
  • Loading branch information...
commit c49943fa45b950be2322223af54a05d17c08f9a3 1 parent ec409b0
Ben Hockey neonstalwart authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 jsgi/session.js
10 jsgi/session.js
View
@@ -21,10 +21,14 @@ exports.Session = function(options, nextApp){
// start the reaper
// TODO: get a timer for narwhal
function validate() {
- exports.getSessionModel().validate();
- setTimeout(validate, options.expires * 1000);
+ // allow for this to occur asynchronously
+ when(exports.getSessionModel().validate(), function () {
+ setTimeout(validate, options.expires * -1000);
+ });
+ }
+ if (typeof exports.getSessionModel().validate === 'function' && typeof setTimeout !== "undefined") {
+ validate();
}
- if (typeof exports.getSessionModel().validate === 'function' && typeof setTimeout !== "undefined") validate();
//
return function(request){
var session;
Please sign in to comment.
Something went wrong with that request. Please try again.