Dump() in route no longers works

Hi all, I’ve just updated a site I’ve been working on to Kirby 4 and I am getting “Cannot modify header information” when I try to dump data in a route. Is there something simple I am missing? This was working before the update. Thanks!

'pattern' => 'resave-links/(:num?)',
'action' => function () use ($kirby) {
  if (kirby()->user() && kirby()->user()->isAdmin()) {

And without the dump part, the error is gone?

Yes, it seems to be fine as long as I don’t output anything. I created a new route to test with and echo instead of dump() and I get the same result.

        'pattern' => 'test-route',
        'action' => function () {
          if (kirby()->user() && kirby()->user()->isAdmin()) {
            echo "Something";

Could this possibly be due to this change? Try...Catch in Response.__toString hides errors · Issue #5027 · getkirby/kirby · GitHub

Looks like you have to set the second param to false

return dump(kirby()->user(), false);

So you have to return something now? I suspected this was the case but in Kirby 3 you could output without returning.

Sorry to hassle you further @texnixe but I just wanted to check if I’m understanding that correctly. Do you know if the error is showing because I am not using return to output instead of just outputting it?

Haven’t really debugged the issue, just tested myself and getting the same error without the return statement.

OK, thanks so much. Good to know it’s not something unique to my situation.