Skip to content

Sentry crashes on every endpoint request #1990

Description

@GENL

How do you use Sentry?

Sentry Saas (sentry.io)

Version

quart==0.18.3
sentry-sdk[quart]==1.19.1

Steps to Reproduce

We have a Sentry Quart integration that worked correctly until today. Since this morning Sentry fails on every API request.
This is the implementation:

from quart import Quart
from sentry_sdk import init as init_sentry
from sentry_sdk.integrations.quart import QuartIntegration

app = Quart(__name__)

init_sentry(
    before_send=filter_sentry_event,
    integrations=[QuartIntegration()],
    traces_sample_rate=0.001,
)

@app.route('/health', methods=['GET'])
def health():
    return {'status': 'pass'}

We have an API with a very simple health check endpoint that returns a success message. Now, when we call that endpoint or any other of our endpoints, Sentry crashes with the stack trace below.
From my testing, before_send never has the chance to be executed. So Sentry fails before before_send gets called.

Note: There was no change to our Sentry's implementation; we haven't updated either the version or the code. It just stopped working.

Thank you.

Expected Result

What is expected is sentry not crashing on API calls.

Actual Result

Sentry crashes with the following stack trace:

2023-04-06 12:23:02,961 [ERROR] hypercorn.error: Error in ASGI Framework
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/hypercorn/asyncio/task_group.py", line 23, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/usr/local/lib/python3.11/site-packages/hypercorn/app_wrappers.py", line 33, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/quart.py", line 83, in sentry_patched_asgi_app
    return await middleware(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/asgi.py", line 139, in _run_asgi3
    return await self._run_app(scope, lambda: self.app(scope, receive, send))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/asgi.py", line 188, in _run_app
    raise exc from None
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/asgi.py", line 183, in _run_app
    return await callback()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1902, in __call__
    await self.asgi_app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1928, in asgi_app
    await asgi_handler(receive, send)
  File "/usr/local/lib/python3.11/site-packages/quart/asgi.py", line 51, in __call__
    _raise_exceptions(done)
  File "/usr/local/lib/python3.11/site-packages/quart/asgi.py", line 353, in _raise_exceptions
    raise task.exception()
  File "/usr/local/lib/python3.11/site-packages/quart/asgi.py", line 90, in handle_request
    response = await self.app.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1654, in handle_request
    return await self.handle_exception(error)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1116, in handle_exception
    await got_request_exception.send(self, exception=error)
  File "/usr/local/lib/python3.11/site-packages/quart/signals.py", line 18, in send
    coroutines = super().send(*sender, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/blinker/base.py", line 297, in send
    raise RuntimeError("Cannot send to a coroutine function")
RuntimeError: Cannot send to a coroutine function

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions