Skip to content
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

onKernelResponse is not triggered in case of exception #124

Open
olix21 opened this issue Mar 21, 2019 · 3 comments
Open

onKernelResponse is not triggered in case of exception #124

olix21 opened this issue Mar 21, 2019 · 3 comments

Comments

@olix21
Copy link

olix21 commented Mar 21, 2019

Hello,

We are using NelmioCorsBundle in an API and if an exception is sent, Symfony does not trigger the kernel.response event but the kernel.exception one.

So the Access-Control-Allow-Origin is not set. It's a little bit annoying as if the http client send a wrong request, the request will blocked by the CORS instead of returning the reason.

Shouldn't we add $this->dispatcher->addListener('kernel.exception', array($this, 'onKernelResponse'), 0);?

@Seldaek
Copy link
Member

Seldaek commented Aug 23, 2019

Yes sounds like that might be correct, feel free to send a PR with a fix

@Seldaek
Copy link
Member

Seldaek commented Feb 15, 2023

I cannot reproduce this somehow, kernel.response still fires for me after kernel.exception is used to generate a response.. Can anyone still repro this?

@mayesto
Copy link

mayesto commented Oct 3, 2023

Hi @Seldaek, this is occurred when you throw some exception in event listener. When exception is thrown in controller everything is ok

Edit: For example event Symfony\Component\HttpKernel\Event\RequestEvent

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

No branches or pull requests

3 participants