8000 [HttpKernel] Deprecate StreamedResponseListener, it serves no purpose anymore by nicolas-grekas · Pull Request #45476 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Deprecate StreamedResponseListener, it serves no purpose anymore #45476

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
Feb 18, 2022

Conversation

nicolas-grekas
Copy link
Member
Q A
Branch? 6.1
Bug fix? no
New feature? no
Deprecations? yes
Tickets -
License MIT
Doc PR -

StreamedResponseListener has been introduced at the same time as StreamedResponse in #2935.

Its purpose was to make catching exceptions easier by wrapping the call to $response->send() in the main try/catch of HttpKernel.

Since #12998, we have HttpKernel::terminateWithException(), and we don't need that anymore, so we can just remove the listener.

This will help integrate Symfony into e.g. Swoole /cc @alexander-schranz.

Copy link
Contributor
@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas Thank you 👍

@fabpot
Copy link
Member
fabpot commented Feb 18, 2022

Thank you @nicolas-grekas.

@DaDeather
Copy link
Contributor

@nicolas-grekas there is an Issue with this change (at least in our case).

It seems to cause the following issue:

When using an StreamedResponse, the Callback passed to StreamedResponse is executed AFTER the \Symfony\Component\HttpKernel\Kernel::handle method (which is doing a pop on the RequestStack in \Symfony\Component\HttpKernel\HttpKernel::finishRequest).

Instead it is executed within the \Symfony\Component\HttpFoundation\Response::send method causing the \Symfony\Component\HttpFoundation\RequestStack to be empty and not having any Request object inside it.

We're upgrading our legacy application which is already wrapped with symfony which is why we're sadly using a construct where we require to inject the \Symfony\Component\HttpFoundation\RequestStack to get the Request which is not available anymore at that state within a StreamedResponse.

Is this really the expected / wanted behaviour for this change? That when using a StreamedResponse the Request object becomes unavailable or is required to be reinitialized manually? If this 8000 is desired it should be announced as a possible BC break.

@nicolas-grekas
Copy link
Member Author

Please don't comment on closed issues/PR as it's likely going to be forgotten. Create a dedicated issue instead or add to an existing one.

@DaDeather
Copy link
Contributor

Please don't comment on closed issues/PR as it's likely going to be forgotten. Create a dedicated issue instead or add to an existing one.

Done: #46743

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.

6 participants
0