Giter VIP home page Giter VIP logo

Comments (7)

Fishrock123 avatar Fishrock123 commented on May 17, 2024

Is it reasonable to just default to a cookie store for this when another store is unavailable?

(or you could just have it cache it in a temporary memory store, but that seems like a bad idea..)

from session.

jonathanong avatar jonathanong commented on May 17, 2024

naw. these sessions could be humongous

from session.

dougwilson avatar dougwilson commented on May 17, 2024

Is it reasonable to just default to a cookie store for this when another store is unavailable?

plus if it is unavailable, how would you get the data out of the store to put into the cookie? :)

from session.

paton avatar paton commented on May 17, 2024

I experienced undefined req.session every so often caused by a disconnected redis store (using ElastiCache).

Here's a workaround that recreates the session middleware with a new Redis connection when the old connection disconnects.

Not sure if it would make sense to attempt a reconnect in the module itself.

app.use((function(){
  var sessionMiddleware;

  var createMiddlware = _.throttle(function() {
    var store = new RedisStore({ ... });
    store.on('disconnect', createMiddlware);

    sessionMiddleware = session({
      store: store,
      cookie: { maxAge: 60000 },
    });
  }, 2000);

  createMiddlware();

  return function(req, res, next) {
    sessionMiddleware.apply(this, arguments);
  };
})());

app.use(function(req, res, next) {
  if (req.session) return next();
  res.send(500, 'Servers are updating. Please check back soon.');
});

from session.

dougwilson avatar dougwilson commented on May 17, 2024

Not sure if it would make sense to attempt a reconnect in the module itself.

It's up to the core to reconnect; the reason this module gives undefined is because you store explicitly told us to do so--a store does not have to do that and just auto-reconnect and you won't experience that, but it's up to the store to do so.

You'll need to report the issue here: https://github.com/visionmedia/connect-redis/issues

from session.

gireeshpunathil avatar gireeshpunathil commented on May 17, 2024

the choice of what to do when the store is unavailable is definitely the application's - based on the use case,

  • one could wait for a while with timeout, if the store becomes auto-available again,
  • one could return an error if the app critically session-sentitive,
  • one could behave as if there was no session

but again, the choice is best left to the application, not the middleware.

I guess this can be closed.

from session.

davidmashe avatar davidmashe commented on May 17, 2024

This issue seems to be stale, was proposed for closing last year with no objections. Closing now.

from session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.