heroku-python / flask-sockets

[DEPRECATED] Alternative: https://github.com/miguelgrinberg/flask-sock
MIT License
1.74k stars 167 forks source link

KeyError is silenced if thrown from inner handler #37

Open lenolib opened 8 years ago

lenolib commented 8 years ago

If a KeyError is thrown in the handler, it will be caught and no log output will be produced. It bit me and it took some time to figure out what was happening. Proposed fix: try-except-KeyError only the environ lookup.

https://github.com/kennethreitz/flask-sockets/blob/master/flask_sockets.py#L47

        except (NotFound, KeyError):
            return self.wsgi_app(environ, start_response)
pddenhar commented 3 years ago

@lenolib I know this is a very old issue, but thank you for pointing me in the right direction after a frustrating hour of debugging a flask-sockets application that would sometimes drop connections completely silently with no error output from Gunicorn.

The culprit was a KeyError in the socket handler, and as noted above KeyErrors are silently absorbed by the library. The solution suggestion above works for me as well.

lenolib commented 3 years ago

@pddenhar It brings me joy that my finding was helpful to you after such a long time.