-
-
Notifications
You must be signed in to change notification settings - Fork 987
Implemented a full featured MemoryStore without leaks #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
6bc2b01
to
ca76303
Compare
👍 😄 |
You might want to look at the replies to a similar pr (#128) as @dougwilson mentioned:
|
Hi everyone, I haven't close this pull request, because there is some possible benefit I can see, but in general, if you haven't already, I recommend publishing a memory store to npm and we can 100% add it to the list of stores! |
I'll wait for a decision whether this is going to be merged or not. There are many cases where we would like developers to do things differently, but they vote with their code. They do it despite our likes and dislikes. It's like the discussions about circular imports in ES6 imports- they ended up being in the specs because people rely on them. |
For the sake of voting, I say nay... It seems a lot like code bloat. |
Then I would rather just remove that completely and force users to need to use redis/mongo/lokijs there by removing these shortcomings. Otherwise yes I'd suggest leaving the memstore as is there is no need for a session library to have a full fledged database/memstore. |
Hi @danielgindi, here are my thoughts on the topic: In an ideal world, one which will happen soon, the core of the session module here will be extracted into a separate module. This module, What I haven't really made up my mind on is what to do about session stories. Yes, this module currently includes one store out of the box: That being said, there is a
I don't really see these shortcomings addressed in this pull request, and they are big gotchas when people create Node.js applications, especially as people deploy to services like Heroku that will automatically run multiple instances of the server. Improving the Besides that, there are a lot of desires from the implementation, especially your over-use of the |
Actually the I don't get one thing. I may be the only one thinking this, but why the heck are people here trying so hard to force other people to do what they think is right? I get it: the ideal is having an external memory store. Devs that need to get their app to production usually understand that there are some steps they have to take to get there, and will come reading about what they have to do for it to happen. .NET users for example- when they start with load balancing they go and read a Microsoft article, and figure out they need an SQL store or a Session Server. |
Honestly I have not looked at the implementation yet, mainly because there are zero tests included in the pull request. The initial suggestion was to publish this to npm as a store module. There is no reason we cannot remove the built-in memory store and replace it with a reference to a module. I'm sorry there are no contribution guidelines yet, but the current pull request is missing the following items to even really be considered to merge, ignoring the debate:
If you are interested, I can go over the code in the PR after those main issues are fixed. I also don't quite understand the objection to publishing as a module to npm, either, especially because it means anyone can benefit, even people using old versions of this module and things like Express 3. |
@dougwilson Thanks for your comments! Regarding the tests - there are tests in the repo, being ran automatically when the PR is created. There were actually some issues that were pointed out by Travis, where the implementation did not behave exactly as expected - and I fixed those. Regarding the code styling, I actually don't see any issues here, as I tried to keep the existing style the same (including commas on the beginning of the next line in objects, etc.). I would love it if you pointed out any styling issues here - as I myself do not like it when people are making PRs to my repos with different code style, it drives me crazy! I will also look into the interval and figure out a way to allow graceful shutdown. You see, even if this will end up on |
@dougwilson is there any standard function being called on the session-store when the express app is shutdown? |
Hi @danielgindi, no, there is no function called on middleware when an express app is shutdown, mainly because there is no concept of an express app being shutdown; the underlying server implementation may stop listening on the socket and a user may clean up all things holding open the event loop, but Express is not a full framework that you may be imaging :) You would build a framework like that on top of Express (like SalisJS). |
9d2e29b
to
408229e
Compare
The current implementation lacks a lot. It does not do a TTL for sessions that have no cookie expiry, and it does not clean up expired sessions so they can leak endlessly.
Of course in express' documentation a MemoryStore is defined as something that should not be used, but there are cases where Redis is an overkill, and you do want a MemoryStore on a single process.
For those cases, I have re-implemented the memory store in a more stable manner, with TTL and with automatic cleanup after expiration.