question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quart ASGI treated as ASGI2 when it should be treated as ASGI3

See original GitHub issue

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? sentry-sdk 1.1.0 (pypi)

Steps to Reproduce

Using the Quart framework, and the ASGI integration provided in the SDK (docs), as well as following the Quart middleware documentation, quart_app.asgi_app is treated as an ASGI 2 app while it should be treated as an ASGI 3 app.

Expected Result

The SDK should work, providing request context for errors.

Actual Result

It seems like integrations/asgi.py#L53 is causing quart_app.asgi_app to report as an ASGI 2 application, erroring out with _run_asgi2() takes 2 positional arguments but 4 were given.

Additionally, creating a new variable based on quart_app, instead of quart_app.asgi_app (sentry_app = SentryAsgiMiddleware(quart_app) and serving that seems to work.

Quoting @pgjones from the Quart Gitter

Ideally it should work with the app.asgi_app, which I think (if it works with app) is the crucial part to put in the bug report to sentry

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pgjonescommented, Feb 14, 2022

I think this is still a sentry bug, however Sentry now ships a Quart integration which doesn’t trigger this bug.

1reaction
augustozanellatocommented, Jul 23, 2021

@arusahni: @augustozanellato had actually posted a cleaner solution in the Quart Gitter; Directly invoking ._run_asgi3 like this: app.asgi_app = SentryAsgiMiddleware(app.asgi_app)._run_asgi3. Again, a preferred solution would be to have the root cause of the issue fixed, but this’ll work for now 😃

I’m 100% sure I found that somewhere on the internet so don’t credit me for that 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying Quart — Quart 0.17.0 documentation
Hypercorn is installed with Quart and will be used to serve requests in development mode by default (e.g. with run() ). To use...
Read more >
Uvicorn
Uvicorn is an ASGI web server implementation for Python. Until recently Python has lacked a minimal low-level server/application interface for async frameworks.
Read more >
Embracing ASGI with Quart; Introducing Hypercorn - Medium
The latest release of Quart, 0.6.0, changes Quart to be a pure ASGI framework and introduces Hypercorn as an ASGI server based on...
Read more >
esg - PyPI
ESG is a speed-oriented ASGI server implementation with HTTP/1.1 and WebSockets support. Is a hard fork of the awesome uvicorn project. Protocol ...
Read more >
Deploy FastAPI with Hypercorn HTTP/2 ASGI | by Ng Wai Foong
Hypercorn supports HTTP/1, HTTP/2, WebSockets (over HTTP/1 and HTTP/2), ASGI/2, and ASGI/3 specifications. Hypercorn can utilise asyncio, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found