-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Exception after kernel.terminate runs kernel.exception, kernel.response and kernel.finish_request listeners again #45205
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
Comments
Also if we go with option 1 it would be great to know whether we are in a pre or post terminate situation in |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
@carsonbot, this issue is still relevant. Hi @fancyweb, I recently encounter an issue which I think seems related to your point. In my TerminateListener an exception is thrown
But like you said the extra response is useless. I think indeed a
should have a early return if the exception was thrown in a terminate event. |
…onse::send() (fancyweb) This PR was merged into the 6.4 branch. Discussion ---------- [HttpFoundation][Runtime] Add $flush parameter to Response::send() | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT Inspired by #51912 and #45205 subjects Adds optional argument `$flush` to `Response::send()`. If `$flush === false`, output buffers are not flushed/`*_finish_request()` and alike functions are not called. We leverage that in the Runtime component by not flushing the output buffers when debug mode is on in order to see exceptions thrown in listeners listening on the `TerminateEvent` and also to feel a more "real" processing time of things happening on terminate. Commits ------- a3304cc [HttpFoundation] Add $flush parameter to Response::send()
Symfony version(s) affected
All
Description
If a
kernel.terminate
listener throws an exception,HttpKernel
ends up dispatchingkernel.exception
again.Then, if a
kernel.exception
listener sets a response,kernel.response
is redispatched a second time while the response has already been sent (a lot of "useless" code is executed).Finally,
kernel.finish_request
is always redispatched a second time.How to reproduce
Throw an exception in a
kernel.terminate
listener.Possible Solution
I think dispatching
kernel.exception
again can make sense. But we should stop there.We can also stop before dispatching it.
Also if this is really a wrong behavior, the subject is probably sensible, I don't think we can treat it as real a bug fix, we would need to deprecate it first.
Additional Context
No response
The text was updated successfully, but these errors were encountered: