-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
On Demand not working with Laravel Octane #592
Comments
@finalgamer have you tried adding Clockwork class to the flush list in |
Hey, thanks for the detailed report, this indeed seems to be a bug, I will have to take a closer look. Though be aware that the Octane support currently has a known limitation, where the Clockwork profiling is always active, even for filtered requests. If you are planning to use the on-demand mode to avoid the performance overhead from running Clockwork for all requests, this unfortunately won't work atm. |
@flexchar What class are you talking about? |
Flushing the resolved instances did not work for me unfortuantely, but for now I got it working by focefully reloading the ClockworkServiceProvider on every request using a Listener: <?php
namespace App\Listeners;
use Clockwork\Support\Laravel\ClockworkServiceProvider;
use Laravel\Octane\Events\RequestReceived;
class ReloadClockworkProvider
{
/**
* Handle the event.
*
* @param \Laravel\Octane\Events\RequestReceived $event
* @return void
*/
public function handle(RequestReceived $event): void
{
$event->sandbox->register(ClockworkServiceProvider::class, true);
}
} and then register it inside 'listeners' => [
...
RequestReceived::class => [
...
ReloadClockworkProvider::class,
], |
@finalgamer I was talking about the main Clockwork class. Adding me helped to fix getting false warnings for duplicate queries. // config/octane.php
'flush' => [
//
\Clockwork\Clockwork::class,
], |
@flexchar That sounds like something we should actually fix in Clockwork itself. :) |
When running with a configured on demand key no requests are captured.
My investigation shows that this is caused because the service provider is only booted on startup of Octane and the event listeners and middleware are not registered.
clockwork/Clockwork/Support/Laravel/ClockworkServiceProvider.php
Lines 27 to 30 in bd13e76
Line 27 will evaluate to false.
Analysis
When the Octane server boots up and registers the service providers and a new empty request is created in the support class.
clockwork/Clockwork/Support/Laravel/ClockworkSupport.php
Lines 661 to 672 in bd13e76
This empty request does not contain the on demand key and thus will fail the
shouldCollect()
call on Line 54clockwork/Clockwork/Support/Laravel/ClockworkSupport.php
Lines 549 to 555 in bd13e76
The end result is that the middleware and event listeners are not registered.
The text was updated successfully, but these errors were encountered: