tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.83k stars 247 forks source link

Arrow function given to Event::listen stops further propagating of the event #723

Closed emielmolenaar closed 5 months ago

emielmolenaar commented 5 months ago

Ziggy version

2.0.3

Laravel version

10.46.0

Description

The arrow function given to the event listener at https://github.com/tighten/ziggy/blob/2.x/src/ZiggyServiceProvider.php#L20 returns boolean false. This makes the dispatcher stop further propagating of the event at https://github.com/laravel/framework/blob/10.x/src/Illuminate/Events/Dispatcher.php#L298 .

This potentially breaks other application functionality, in our case Laravel Telescope when using Octane. Telescope also listens to the Laravel\Octane\Events\RequestReceived event but the dispatcher never invokes listeners because the arrow function BladeRouteGenerator::$generated = false returns false. This makes Telescope not record any requests.

I think a fix would be to revert back to a "regular" function in the Event::listen() call in https://github.com/tighten/ziggy/blob/2.x/src/ZiggyServiceProvider.php#L20 so the function does not return false. If we all agree to that I'm willing to write a quick PR for that, let me know.

Ziggy call and context

Not applicable

Ziggy configuration

Not applicable

Route definition

Not applicable
bakerkretzmar commented 5 months ago

Yikes, yeah that's not good. Thanks! Will get a fix in right now.

emielmolenaar commented 5 months ago

Great, thanks for the quick response! 👍🏻