sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Sentry reporting anomalous ConnectionError in flask_sock

Open sanchay-hai opened this issue 2 years ago • 4 comments

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?

sanchay-hai avatar Sep 12 '23 00:09 sanchay-hai

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.

antonpirker avatar Sep 15 '23 07:09 antonpirker

Any update on this?

sanchay-hai avatar Sep 21 '23 22:09 sanchay-hai

Not yet, sorry

antonpirker avatar Sep 27 '23 15:09 antonpirker

Hey @sanchay-hai, have you tried using a custom before_send (see docs) for this?

sentrivana avatar Jul 01 '24 12:07 sentrivana

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 🥀

getsantry[bot] avatar Jul 23 '24 07:07 getsantry[bot]

@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 avatar Jul 23 '24 16:07 sanchay-hai

@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.

sl0thentr0py avatar Jul 24 '24 09:07 sl0thentr0py

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.

sanchay-hai avatar Jul 24 '24 15:07 sanchay-hai