Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #21 from neonstalwart/session-validate-interval

Session validate interval
  • Loading branch information...
commit c69d321ff2a5fff7fc66f023fc12010ce67d0ba8 2 parents 617909c + c49943f
@kriszyp kriszyp authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 jsgi/session.js
View
12 jsgi/session.js
@@ -20,9 +20,15 @@ exports.Session = function(options, nextApp){
if (!options.expires) options.expires = -(settings.sessionTTL || 300);
// start the reaper
// TODO: get a timer for narwhal
- if (typeof exports.getSessionModel().validate === 'function' && typeof setTimeout !== "undefined") setTimeout(function(){
- exports.getSessionModel().validate();
- }, options.expires*1000);
+ function validate() {
+ // 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();
+ }
//
return function(request){
var session;
Please sign in to comment.
Something went wrong with that request. Please try again.