I'm using Laravel Horizon which has a Failed Jobs section which used to work fine. Until I added the Sentry notification for failed jobs, in Job's Class.
/**
* Handle a job failure.
*
* @return void
*/
public function failed(\Exception $exception)
{
if ( app()->bound('sentry') ) {
app('sentry')->captureException($exception);
}
}
Now, when visiting the Failed Jobs tab in Horizon - it results in fatal error with memory exceeded. How can I make both Horizon and this sentry notification work?
You can create command to clean up older records of failed_jobs
table.
public function handle()
{
// mention days count as required
DB::table('failed_jobs')->where('failed_at', '<', now()->subDays(10))->delete();
}