Gunicorn

ASGI disconnect message requires active monitoring

info
configurationUpdated Mar 1, 2026(via Exa)
Technologies:
How to detect:

Under the ASGI specification, the server sends an http.disconnect message when client connection is lost, but the application must actively monitor this message or use a mechanism that cancels the task when connection is severed. Without explicit handling, requests continue executing after client disconnect.

Recommended action:

Implement cancellation-aware wrapper or middleware that listens to the receive channel for http.disconnect type. When detected, trigger cancellation of the task running the send channel logic. Alternatively, ensure application logic properly handles asyncio.CancelledError which Uvicorn raises when socket closure is detected.