Closed gregory-claeyssens closed 10 months ago
We need a bit more info, please, like the Laravel version. Is anything custom in terms of SDK setup? Anything else you can think of?
I got the same error.
We are using Laravel Vapor.
The problem, from what I understand from the code, is that Laravel Vapor instantiates the console kernel
$app->make(ConsoleKernelContract::class)->call('config:cache');
in vendor/laravel/vapor-core/stubs/fpmRuntime.php
, but the isApplicable()
function on ConsoleIntegration
, returns true only when running in console.
My solution right now is to add
protected function addSentryMonitorMacro()
{
if(!SchedulingEvent::hasMacro('sentryMonitor')) {
SchedulingEvent::macro('sentryMonitor', function (
?string $monitorSlug = null,
?int $checkInMargin = null,
?int $maxRuntime = null,
bool $updateMonitorConfig = true
) {
return $this;
});
}
}
to the Console Kernel and to run it at the beginning of the schedule()
method: $this->addSentryMonitorMacro();
I think the same issue would happen if you try to run any artisan command, while not running in the console
later edit:
The solution that fixed this and that can be implemented easily in sentry laravel, is to always load the empty macro. This doesn't affect the functionality, as the macros are overwritten later.
This is the updated constructor for ConsoleIntegration
public function __construct(Container $container)
{
parent::__construct($container);
$this->onBootInactive();
}
@stayallive can you take a look please?
Interesting, I'll take a look this seems like something we can fix. At least the Vapor case, unsure if the OP has the same issue but we might solve it anyway. Thanks for the detailed report!
I submitted a PR for this, the better solution I think is to do it in the register()
method of ConsoleIntegration
.
As I wrote in the PR, you can replicate this easily by doing Artisan::call('inspire');
in a controller.
How do you use Sentry?
Sentry SaaS (sentry.io)
SDK version
4.0.0
Steps to reproduce
Following the documentation to the letter by adding
->sentryMonitor()
Example:Expected result
It simply work
Actual result
An error is logged in Sentry
Method Illuminate\Console\Scheduling\Event::sentryMonitor does not exist.