Sentry reporting anomalous ConnectionError in flask_sock
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.29.2
Steps to Reproduce
This code should reproduce (I haven't tested)
from flask_sock import Sock
from flask import Flask
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
app = Flask(__name__)
socket = Sock(app)
@socket.route("/myroute")
def myroute(ws):
while ws.connected:
ws.receive()
sentry_sdk.init(dsn=<>, integrations=[FlaskIntegration()])
Expected Result
I think maybe sentry shouldn't report this error since socket handler is returning successfully from the application
Actual Result
After the socket successfully closes, sentry reports a ConnectionError from underlying flask_sock library. Here is the code from where that ConnectionError is raised: https://github.com/miguelgrinberg/flask-sock/blob/main/src/flask_sock/init.py#L86
We don't get any error on the console or logs, but sentry reports a ConnectionError. Not sure why?
Hey @sanchay-hai, thanks for reporting this.
Currently we are a bit swamped so it will take some until until we can look at this. So please be patient.
Any update on this?
Not yet, sorry
Hey @sanchay-hai, have you tried using a custom before_send (see docs) for this?
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
@sentrivana everyone shouldn't have to build a custom before_send for this. This should be ideally handled by sentry. Maybe sentry can provide a default before_send with this behavior
@sanchay-hai this is very simple to ignore with a before_send as mentioned above or just
sentry_sdk.init(ignore_errors=[ConnectionError])
We cannot make assumptions for every user if their use case is to be ignored which is why we provide hooks. From the information you provided, I cannot be certain this is a general problem or a problem with your particular usage.
I am closing this since you can very easily fix this on your end.
Not sure how this is application's responsibility. This is an issue with the way sentry detects errors. This ConnectionError is raised internally within the flask_sock library and then caught internally.