laravel / horizon

Dashboard and code-driven configuration for Laravel queues.
https://laravel.com/docs/horizon
MIT License
3.87k stars 658 forks source link

Manifest.json cause 404 error if file in resources is missing #1416

Closed nathanaelytj closed 7 months ago

nathanaelytj commented 7 months ago

Horizon Version

5.24.1

Laravel Version

11.4.0

PHP Version

8.3.4

Redis Driver

PhpRedis

Redis Version

7.2.4

Database Driver & Version

No response

Description

This update cause a bug when opening horizon dashboard with error like: GET http://localhost:5173/resources/js/app.js net::ERR_ABORTED 404 (Not Found) GET http://localhost:5173/resources/sass/styles.scss net::ERR_ABORTED 404 (Not Found)

This is because in some of our project we don't use js anymore but ts files also we don't use styles.scss as entrypoint anymore but another file. This issue will also break any project without those files as entrypoint.

After reading commit history, this file seems to be the culprit: public/build/manifest.json

Steps To Reproduce

  1. Create new laravel project
  2. Install horizon
  3. Remove or rename file resources/js/app.js and resources/sass/styles.scss
  4. Open horizon dashboard and this issue will happen
driesvints commented 7 months ago

Did you publish the new assets like: https://github.com/laravel/laravel/blob/11.x/composer.json#L39

php artisan vendor:publish --tag=laravel-assets --ansi --force
driesvints commented 7 months ago

@mmachatschek Should we possible use a different name for the manifest file? Like horizon-manifest? https://github.com/laravel/horizon/pull/1415

bramdevries commented 7 months ago

We also updated to the latest Horizon version (5.24.1) and this only seems to be an issue on local environments when running npm run dev since https://github.com/laravel/horizon/pull/1413. I have a bit more info from debugging:

The issue seems to be that when you run npm run dev it will use a different path (from the application's vite.config.js) and attempt to resolve the Horizon dependencies from the resources directory instead of vendor/horizon. If you don't run npm run dev then the assets will load correctly again.

While the layout loading the assets with Vite:asset() correctly passes the build directory, this is ignored when running in "hot" mode (which is what npm run dev does).

driesvints commented 7 months ago

Reverted everything for now. Thanks all for reporting.

mmachatschek commented 7 months ago

thanks @bramdevries thanks for the debugging info. Will check that