Gunicorn (Uvicorn Worker) continues processing requests after Heroku 30s timeout
I’m running a Django (ASGI) app on Heroku using Gunicorn with the Uvicorn worker to support WebSockets.
Heroku has a hard 30-second request timeout. When a request exceeds 30 seconds, Heroku closes the connection as expected.
Problem: Even after the Heroku timeout, Gunicorn/Uvicorn continues executing the request in the background, which wastes resources.
Gunicorn command:
newrelic-admin run-program gunicorn --workers 4 --worker-connections 200 --timeout 30 --max-requests 1000 --max-requests-jitter 500 --bind 0.0.0.0:8000 asgi:application
Questions
Why does Gunicorn/Uvicorn keep running the request after Heroku times out?
Is there a way to cancel the request when the client disconnects?
Should this be handled in Django (async cancellation/middleware), or via Gunicorn settings?
Any help is appreciated.