Symfony 5: 500 errors are not catched in prod environment

I have a strange problem in a symfony 5.3.10 app and i can’t wrap my head around it.

If i trigger a 500 error, like so:

/**
 * @Route("/", name="pvr_index", methods={"GET"})
 */
public function index(): Response
{
    echo $a;

Where $a is not defined, in dev environment i get a nice error page.

I’d expect that in prod i would get a not so nice error page that just tells me that i have a 500 error. And this would happen correctly until some time ago, when something changed, but i don’t know what.

Now instead i get no error, not even in the symfony server console, and the script execution would keep on going like nothing happened.

What i tried:

Adding the supposed exception inside a try/catch:

try {
        echo $a;
    }
    catch (Exception $e)
    {
        dump($e);
        die();
    }

Nothing happens, the catch isn’t triggered.


Creating an exception listener:

In services.yaml i have:

exception_listener:
    class: AppEventExceptionListener
    tags:
        - { name: kernel.event_listener, event: kernel.exception }

And in ExceptionListener.php i have:

class ExceptionListener
{
    public function __construct(Environment $engine) {
        $this->engine = $engine;
    }
    public function onKernelException(ExceptionEvent $event)
    {
        dd($event->getThrowable()->getMessage());
    }
}

Still nothing happens, the listener isn’t triggered.

Everything works as expected in dev environment, the problem presents itself only in prod.

Looking at a phpinfo(); page i see that the error reporting is enabled, so i think that the problem lies in the symfony configuration.

I’m using php 7.4 and have no real access to the php.ini file