Opened 3 weeks ago

Closed 3 weeks ago

#36628 closed Bug (wontfix)

StreamingHttpResponse doesn't send final ASGI more_body=False signal

Reported by: Louis Amon Owned by: Louis Amon
Component: HTTP handling Version: 5.2
Severity: Normal Keywords: streaming, vercel, asgi
Cc: Louis Amon, Carlton Gibson Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Django's StreamingHttpResponse does not send the final ASGI more_body=False
signal when streaming responses are exhausted.

This causes compatibility issues with ASGI servers like Vercel's custom handler that require this
signal to properly finalize responses.

Reference:
https://github.com/vercel/vercel/blob/main/packages/python/vc_init.py#L646

Change History (4)

comment:2 by Sarah Boyce, 3 weeks ago

Cc: Carlton Gibson added

Noting that #33738 is likely related, especially this comment.

comment:3 by Carlton Gibson, 3 weeks ago

#33738 was about handling multiple body events when parsing the request. This here is about the response. In both cases, a more_body=True entails that there's more to come (but they're not otherwise related).

The spec here for Response body events is clear (my emphasis added):

more_body (bool) – Signifies if there is additional content to come (as part of a Response Body message). If False, and the server is not expecting Response Trailers response will be taken as complete and closed, and any further messages on the channel will be ignored. Optional; if missing defaults to False.

That is, if more_body is missing, it should be assumed to be False. (It's optional and emitting it is not an error.)

Looking at the Vercel code, it already does this, so I can't quite see from the information given what the problem is. 🤔

comment:4 by Sarah Boyce, 3 weeks ago

Resolution: wontfix
Status: assignedclosed

Thank you Carlton
Louis you will need to add more information to explain the ticket and how Django is at fault before reopening

Note: See TracTickets for help on using tickets.
Back to Top