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

FlaskIntegration causes gunicorn worker to raise AttributeError while switching protocols #724

Closed
eelkevdbos opened this issue Jun 19, 2020 · 5 comments

Comments

@eelkevdbos
Copy link

I am using a Flask, -SocketIO, Gunicorn, eventlet based websocket endpoint on a single gunicorn worker. Everything works fine until I start adding the FlaskIntegration for the sentry_sdk.

#requirements.txt
Flask==1.1.2
Flask-SocketIO==4.3.0
gunicorn==20.0.4
eventlet==0.25.2
sentry-sdk==0.15.1

After adding the FlaskIntegration, upon switching protocols (HTTP 101), the following exception occurs:

[2020-06-19 07:21:33 +0000] [24] [ERROR] Error handling request /socket.io/?EIO=3&transport=websocket
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 115, in handle_request
    resp.close()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 402, in close
    self.send_headers()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 318, in send_headers
    tosend = self.default_headers()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 299, in default_headers
    elif self.should_close():
  File "/usr/local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 219, in should_close
    if self.status_code < 200 or self.status_code in (204, 304):
AttributeError: 'Response' object has no attribute 'status_code'

The end-user (browser) is not notified of this exception, the error is logged by sentry nonetheless.

@untitaker
Copy link
Member

This appears to be a gunicorn bug, see: miguelgrinberg/Flask-SocketIO#223

@eelkevdbos
Copy link
Author

@untitaker That specific issue seems very old (and solved). Is it possible with the current sentry_sdk to switch to synchronous logging to reduce possible sources of eventlet chaos? I think it would help me to track down some details while keeping the advantages of having sentry logging.

@untitaker
Copy link
Member

I'm sorry, I don't know what you mean by synchronous logging.

@untitaker
Copy link
Member

untitaker commented Nov 2, 2020

Closing due to inactivity. The stacktrace does not really exhibit any indication that this has anything to do wtih the SDK at all

@ziddey
Copy link

ziddey commented Nov 2, 2020

for what it's worth, anyone affected can use this workaround for the time being: benoitc/gunicorn#1852 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants