From bdca33f858a8dda0e4ebf6acb95b27ab21895509 Mon Sep 17 00:00:00 2001 From: Reon90 Date: Wed, 9 Nov 2016 00:47:57 +0300 Subject: [PATCH 1/2] memory leaks if used connect-mongo store --- index.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/index.js b/index.js index 2241d974..a50ae8f1 100644 --- a/index.js +++ b/index.js @@ -166,15 +166,6 @@ function session(options) { var storeImplementsTouch = typeof store.touch === 'function'; - // register event listeners for the store to track readiness - var storeReady = true - store.on('disconnect', function ondisconnect() { - storeReady = false - }) - store.on('connect', function onconnect() { - storeReady = true - }) - return function session(req, res, next) { // self-awareness if (req.session) { @@ -182,14 +173,6 @@ function session(options) { return } - // Handle connection as if there is no session if - // the store has temporarily disconnected etc - if (!storeReady) { - debug('store is disconnected') - next() - return - } - // pathname mismatch var originalPath = parseUrl.original(req).pathname; if (originalPath.indexOf(cookieOptions.path || '/') !== 0) return next(); From 4cdefe9d8c0bc98ce8da84b14076b3fef07b068d Mon Sep 17 00:00:00 2001 From: Reon90 Date: Sun, 25 Dec 2016 18:21:43 +0300 Subject: [PATCH 2/2] migration from connect-mongo to connect-mongodb --- session/store.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/session/store.js b/session/store.js index 387469c5..58010659 100644 --- a/session/store.js +++ b/session/store.js @@ -84,6 +84,10 @@ Store.prototype.load = function(sid, fn){ */ Store.prototype.createSession = function(req, sess){ + if (typeof sess === 'string') { + sess = JSON.parse(sess); + } + var expires = sess.cookie.expires , orig = sess.cookie.originalMaxAge; sess.cookie = new Cookie(sess.cookie);