Sentry-python: Django 3.1 async views do not work

Created on 5 Oct 2020  路  2Comments  路  Source: getsentry/sentry-python

When using sentry versions greater than 0.16.3, (tested on 0.18.0), Django 3.1 aysnc views do not work.

log.py                     224 ERROR    Internal Server Error: /async_ok
Traceback (most recent call last):
  File "/Users/williamchu/dev/sentry-python/.tox/py3.8-django-3.1/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/williamchu/dev/sentry-python/.tox/py3.8-django-3.1/lib/python3.8/site-packages/django/core/handlers/base.py", line 186, in _get_response
    self.check_response(response, callback)
  File "/Users/williamchu/dev/sentry-python/.tox/py3.8-django-3.1/lib/python3.8/site-packages/django/core/handlers/base.py", line 312, in check_response
    raise ValueError(
ValueError: The view tests.integrations.django.myapp.views.async_ok didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view.

I have made a branch with a test case to demonstrate this: https://github.com/uptickmetachu/sentry-python/tree/django3.1-test-async-view

bug

Most helpful comment

Thanks and sorry, I found the issue. It will take some time to fix. In the meantime please work around this like so:

sentry_sdk.init(integrations=DjangoIntegration(middleware_spans=False))

All 2 comments

Thanks and sorry, I found the issue. It will take some time to fix. In the meantime please work around this like so:

sentry_sdk.init(integrations=DjangoIntegration(middleware_spans=False))

Tested these changes and they fix my problem :)

Was this page helpful?
0 / 5 - 0 ratings