-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] ErrorListener::onKernelException should ignore exception thrown after kernel.terminate
#51912
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
The current logic might actually be "OK" enough. |
That's why I proposed adding a But maybe things should be thought differently:
somewhere in the |
On my side I think #52047 is the way to go.
Why not, but then this creates an opportunity to hide errors, so at least the early return should also check if we're in debug mode, and skip the exception only if not.
nope, that's too hacky. |
…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()
Something like this #52128 ? |
Symfony version(s) affected
all
Description
Related to #45205 issue, which was ignored...
When an exception is thrown in a
kernel.terminate
event,kernel.exception
is thrown$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
is calledErrorController
and then theTwigErrorRenderer
TwigBundle/Exception/error.html.twig
which use the session and/or flashbag and I'm getting some
Failed to start the session because headers have already been sent
.Introducing a
kernel.terminate_exception
and using it instead ofkernel.exception
could even appear as a BC break forkernel.exception
listeners or a bugfix because according to the schema in the doc https://symfony.com/doc/current/components/http_kernel.html#handling-exceptions-the-kernel-exception-event, we can see the orderException -> Response -> Terminate
.How to reproduce
kernel.terminate
listener -> You'll get extra code executed for no reasonapp.session.flashbag.get('success')
call in a customTwigBundle/Exception/error.html.twig
template. -> You'll get failed to start the session error in your logs.Possible Solution
Either throw a different event for exception thrown after the terminate exception
Either, at least provide a
ExceptionEvent::isTerminated
orTerminableInterface::isTerminated
, which would allow to writeat the beginning of some ExceptionListener like the ErrorListener
Additional Context
No response
The text was updated successfully, but these errors were encountered: