-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Redis down fix #2277
Redis down fix #2277
Conversation
…the session state yet, this fixes that
Awesome! simple solution for a big blocker. Hopefully @sgress454 agrees on merging this 👍 . Thanks! |
After looking into this, it seems to me that the only part that causes Sails to crash is the socket store. Your changes to loadSocketIO.js definitely fix that. If you're only using Redis for sessions, Sails won't crash when Redis goes down--it'll just show:
This is an ugly and misleading message (it has nothing to do with parsing an HTTP body), but that's a separate problem that deserves a more comprehensive solution. So, I'd accept a modified version of this PR without the changes to the http hook and the |
I have no problem with reverting that part, however, here's my justification for it: Anyway, I'm happy to remove that portion, but I feel that while waiting for redis-connect to fix the event handling, it would be nicer to show users a 500 instead... What do you think? |
Yes, I agree the error is misleading and needs a fix, but the fix you're proposing will only handle cases where the origin of the problem is a missing Redis session. What we really need is a generic error handler middleware; right now the |
@sgress454 removed the middleware, I also touched up the error messaging - let me know if you have any notes on that. As a sideline, if you can give some direction as to what you'd like a generic error handler middleware to look like, I could work on that as the http parse error is blocking something we're doing with our project. Thanks |
@Chuwiey I'll give it some thought. How is the parse error blocking you, and was it somehow solved by that additional middleware? The current middleware sends back a 400 error with that "http parse error" string, which you can check for as easily as checking for a 500... |
@sgress454 The issue was the amount of time it took for the app to respond with the 400; I deal with a rather high amount of requests coming in, and it seems that it takes a couple of seconds for each request that fails on http parse to come back. The middleware I created basically responded immediately because it didn't try the redis client first. Also, I wanted to present users with a nice page talking about an error (whether 500 or 400 doesn't matter). Maybe I'll use some sort of catch all at the app level, we'll see. Thanks for merging. |
This is related to the issue I filed earlier today: #2276
If I set the session and socket stores (or one of them) to use Redis as the adapter, and Redis goes down (for whatever reason), sails has an un-handled exception and crashes. It's actually really easy to fix this and make Sails send a 500 while Redis is down, and then when it comes back up, just re-connect.
Steps to reproduce current bug:
I ran the tests, and everything seems to work.
Thanks!