Skip to content
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

RedisSessionInterface: Flask context not popped on Redis issues #82

Closed
kilianm opened this issue Nov 14, 2017 · 1 comment
Closed

RedisSessionInterface: Flask context not popped on Redis issues #82

kilianm opened this issue Nov 14, 2017 · 1 comment

Comments

@kilianm
Copy link

kilianm commented Nov 14, 2017

Redis exceptions on open_session make Flask crash painfully, not popping the context correctly (leaking data across requests).
Flask doesn't catch any possible exceptions on the session_interface, resulting in messing up the context.

To reproduce

  1. Set some parameter in flask.g
  2. Initiate RedisSessionInterface on an invalid redis server (redis.exceptions.ConnectionError or any other, we had sometimes Timeout exceptions).
  3. The next requests contains the old flask.g - context not popped

Fix
Ideally Flask uses its interfaces safely - always popping context. Bug created: pallets/flask#2517
Still, I think it would be nice that Flask-Session is safe as well, catching possible redis problems and not letting Flask deal with the exceptions.

Environment
Python version: 2.7.6
Flask version: 0.10.1
Werkzeug version: 0.11.11
Flask-Session: 0.3.1

@Lxstr
Copy link
Contributor

Lxstr commented Mar 11, 2024

The heart of this issue is fixed in flask pallets/flask#2254.

Regarding handling in flask-session, I think it is better to use SESSION_REDIS = Redis(host='localhost', port=6379, retry=retry, retry_on_error=[BusyLoadingError, ConnectionError, TimeoutError])

@Lxstr Lxstr closed this as completed Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants