-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flux js and css routes crash after artisan optimize #998
Comments
@vorban I believe this related to a known Livewire issue - when views are cached it can cause problems. |
@jeffchown mmh I've looked at the linked PR and it doesn't seem related to me. I'm talking about route caching here - not views. Looking at the code, it's a different mechanism at hand. My issue is concerned with the caching of Flux's routes. Because the routes where written with inlined callbacks (or anonymous functions) the cache serializes them through PHP reflection, effectively hardwiring an absolute path at the time of execution. The proposed solution is a simple rewrite of the callbacks as named functions, basically an actual controller. Seems much easier to solve. |
@vorban Thanks for the further explanation. I have to admit, as soon as I saw Could it be the same issue with any Flux/Livewire cached routes? e.g. Maybe they need to be compiled/composed at execution by Livewire/Flux and when cached that can't happen? If that is it, it's definitely not ideal as it would, at least for now, indicate we have to avoid both As I haven't done a deep dive into the related code, this is strictly me thinking out loud as to the possibilities. |
Flux version
v1.1.0
Livewire version
v3.5.17
What is the problem?
The AssetManager.php declares routes to flux's assets, via callback: AssetManager.php#L43:
The callback contains a
__DIR__
.When deploying through vapor (
vapor deploy production
) without a CI/CD pipeline, theartisan optimize
command is run in the context of the local machine. This is usually not a problem, except if a route is an inlined callback, in which case the callback is fully serialized. See the./bootstrap/cache/routes-v7.php
file:The important part is
\'/Users/vorban/repositories/github/my-repository/vendor/livewire...
-> this is an absolute path on my machine.After a successful deployment, we get HTTP 500 on the flux routes:
We can bypass this issue by omitting
artisan optimize
from the vapor build commands.Code snippets
No snippet required. Install flux, and run
php artisan route:cache
orphp artisan optimize
. Observe the route cache file.How do you expect it to work?
We'd expect flux routes to have the same behaviour, with or without
artisan optimize
, regardless of the context of execution.Declaring a regular controller to handle the routing could be a potential fix (although I haven't had the time to test this myself), as there would be no callback to serialize.
Please confirm (incomplete submissions will not be addressed)
The text was updated successfully, but these errors were encountered: