laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.75k stars 291 forks source link

Intermittent unresolvable dependency #267

Closed ju5t closed 3 years ago

ju5t commented 3 years ago

Description:

I'm getting an intermittent error in our app when testing with Octane. It's always this error:

Illuminate\Contracts\Container\BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ <required> $methods ]] in class Illuminate\Routing\Route

It happens on all URL's. But not all the time. It's pretty difficult to replicate.

Some background details:

We have both full-page Livewire components (routes point directly to Livewire) and normal controllers. We get this specific error on Livewire components only. Normal controllers seem to be loading an old version of the controller every now and then, multiple restarts made no difference.

Switching to Swoole seems to fix the issue.

If you need more information, let me know. This is a private repository but I'm OK sharing our code in private if needed.

Steps To Reproduce:

I was a little hesitant to open this issue because although it does happen, I have not been able to find a consistent way to replicate the issue :(

nunomaduro commented 3 years ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to report back and I'll gladly help you out and re-open this issue.

Thanks!

ariaieboy commented 3 years ago

@nunomaduro i have the same issue with livewire full-page components its completly random and after multiple refreshes the error will disappear

Sail version : 1.8.3 laravel version : 8.49.0 livewire version : 2.5.1 octane: 1.0.7 swoole version : 4.6.7

ariaieboy commented 3 years ago

i also tested this on a fresh install livewire and another code base and the issue reproduced for me in both of my projects

dimitri-koenig commented 3 years ago

Same here. What works is running artisan optimize, which is fine for production but not for local development.

saulens22 commented 3 years ago

Try running artisan optimize:clear. Fixed everything for me.

ju5t commented 3 years ago

@dimitri-koenig @saulens22 cool! We've postponed our switch to Octane for now as Forge doesn't support switching yet and we don't want to migrate, but having a workaround is awesome!

ariaieboy commented 3 years ago

@saulens22 optimize:clear not working for me i need to first do artisan optimize then reload the octane so the error go away but as @dimitri-koenig said its good for production but in development its very annoying

afiqiqmal commented 3 years ago

Jetstream TALL stack full page component with Octane will cause this BindingResolutionException problem. Its happen when you updating the livewire value and when switching page, BindingResolutionException occured. I need to keep restart the octane in the development. Really annoying BTW

brocorp-dev commented 3 years ago

Hi guys,

We encountered same issues with Livewire Full Page components and Laravel Octane (Swoole) on a staging server, which generate a global 500 Server Error.

PHP version : 8.0.2 Laravel version : 8.49.1 Octane version : 1.0.7 Swoole version : 4.6.6

Hosted on a DigitalOcean Droplet (2vCPU, 2GB RAM) CPU usage : between 3 and 16% RAM usage : between 68% and 76%

This droplet host also

Error message encountered : Unresolvable dependency resolving [Parameter #0 [ $methods ]] in class Illuminate\Routing\Route

It's difficult to know the exact cause of this exception: logs are not precise about this and there is no previous event before.

Unlike other cases, we didn't run php artisan optimize command before on this server.

Currently, only the php artisan octane:reload command can "solve" the problem, which is relatively tedious.

cihantas commented 3 years ago

Can we please reopen this issue? My company has the same issue in development and my fear is that this might also happen randomly after a production deployment.

The data points above raise the likelihood that this is indeed a bug in Octane. I had trouble finding this issue. Reopening it will increase visibility and might attract more Octane users to add data points.

ariaieboy commented 3 years ago

Can we please reopen this issue? My company has the same issue in development and my fear is that this might also happen randomly after a production deployment.

The data points above raise the likelihood that this is indeed a bug in Octane. I had trouble finding this issue. Reopening it will increase visibility and might attract more Octane users to add data points.

do you use livewire fullpage component and you have this issue or its happens in different situations ?

since for livewire fullpage component optimizing the cache will fix the issue we can start debugging from that point and check that what is not loading currectly when configs is not cached that this errors happens.

i worked almost 2 days on this issue but i didnt find anything that can solve the problem if i find some free time in my schedule maybe i work on it again so maybe i found a solution.

dimitri-koenig commented 3 years ago

I'm still on it since this bugs me too. So far I've found two more workarounds:

  1. Running only route:cache instead of optimize, before starting octane
  2. Running octane:start with this option: --max-requests=1

My working guess is that somehow routes are not properly processed/warmed/cached during initialization of a new request. Something is off there.

Hope that helps for the time being.

@nunomaduro Do you mind opening this issue again since this is a very annoying bug which needs fixing quickly?

dimitri-koenig commented 3 years ago

So, I found the issue and created a pull request: https://github.com/livewire/livewire/pull/3495

Anyone who wants to test too may do so. For me it's working fine without any issues anymore.