#36193 closed Bug (invalid)
AssertionError: Invalid ASGI message after request body: http.request
Reported by: | Dominik Gasparic | Owned by: | |
---|---|---|---|
Component: | HTTP handling | Version: | 5.0 |
Severity: | Normal | Keywords: | ASGI, http.disconect, |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I suspect that with the feature introduced from Django 5.0 for handling http.disconnect events. Something might be problematic under certain conditions with async views in Django. I only saw this happening with Nginx Unit and Django>=5.0. https://code.djangoproject.com/ticket/33738
Here is also the ticket on Nginx Unit github https://github.com/nginx/unit/issues/1561 it contains traceback, Unit log and behavior described in more detail.
I also created demo project to reproduce this behavior: https://github.com/codedoga/nginx_unit_asgi_django
Another thing I noticed is that if I override ASGIHandler with the one used by Django<=5.0 it works without issues.
Change History (2)
comment:1 by , 4 days ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 3 days ago
This looks like Unit isn't correctly handling the more_body
key of the http.request
event.
https://asgi.readthedocs.io/en/latest/specs/www.html#request-receive-event
After an http.request
event where more_body
is False
the only permitted event is http.disconnect
. Hence the assertion.
Hi Dominik, thank you for the ticket
In the issue you raised to Nginx Unit, you mentioned
This doesn't look like Django is at fault to me.
Please use our support channels for help in identifying the source of the issue. There are volunteers who can help to figure out what is going on here.
If after further investigation, it is confirmed that Django is at fault, please re-open with more details.