Skip to content

[HttpFoundation] Fix flush after echo in StreamedResponse #60262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Apr 24, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

The StreamedResponse doesn't flush after echoing. Therefore, all the chunks are kept in output buffer, which prevents proper streaming.

This PR triggers flushes after each echo.

@mtarld mtarld force-pushed the fix/flush-streamed-response branch from dfa336e to bf72397 Compare April 27, 2025 09:21
@fabpot
Copy link
Member

fabpot commented Apr 27, 2025

Thank you @mtarld.

@fabpot fabpot merged commit a2a47bc into symfony:7.3 Apr 27, 2025
9 of 11 checks passed
@xabbuh
Copy link
Member

xabbuh commented Apr 27, 2025

Should we update the class docblock now and remove the part about calling flush().

@chalasr
Copy link
Member

chalasr commented Apr 27, 2025

@xabbuh I don't think so. The added flush is only used by the callback that is created internally when the response is built with an iterable of content chunks, while that docblock suggests flushing from the user-defined callback you can pass instead of the chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants