spatie / laravel-horizon-watcher

Automatically restart Horizon when local PHP files change
https://spatie.be/open-source
MIT License
218 stars 15 forks source link

When stopping the watcher each time an exception is thrown. #35

Open gldrenthe89 opened 1 month ago

gldrenthe89 commented 1 month ago

Hi there,

I just started using this package. Before i was using nodemon npm package. The package is working fine but when stopping the process an exception is thrown: Spatie\Watcher\Exceptions\CouldNotStartWatcher

I am using Laravel Herd Pro for local development. Using Node 22.29.0, PHP 8.3.12, Redis 7.0.0 and Mysql 8.0.36 with latest updates installed from within Herd Pro

I have correctly installed the npm package 'chokidar' per documentation. It is on v4.0.1

Image

jackwh commented 1 month ago

I've had this problem occurring randomly for over a year, I'm not sure what the root cause is but it's definitely annoying!

As a workaround you can suppress this exception in bootstrap/app.php:

    ->withExceptions(function(Exceptions $exceptions) {
        $exceptions
            ->dontReportDuplicates()
            ->dontReport(\Spatie\Watcher\Exceptions\CouldNotStartWatcher::class);
    })
gldrenthe89 commented 1 month ago

Sometimes different Node versions will affect the behavior of some packages. You can try to use the LTS version of Node (such as 18.x) for testing. You can choose Servbay to switch the environment. Servbay supports one-click switching of Nodejs versions.

Hi thanks for the comment. I am actually using Laravel Herd Pro. I can switch Node very easely but this project needs Node 22. So unfortunatily i cant switch every time is start using this package. The package works fine, it is just this annoying little exception when stopping the watcher.

When i find the time i can try debug it myself. I whas just wondering if this something everybody has?