Skip to content

When scout encounters timeout, the jobs never fail in Horizon and block the queue #957

@einenlum

Description

@einenlum

Scout Version

10.22.1

Scout Driver

Typesense

Laravel Version

12.42.0

PHP Version

8.4.1

Database Driver & Version

No response

SDK Version

No response

Meilisearch CLI Version

No response

Description

I encountered a weird issue recently.

I commented my Typesense credentials in my .env and it of course failed to send scout requests on deployment (no surprise here).

But what I found out is that because of how the MakeSearchable job is configured, when the job receives a timeout, it never fails and is still pending in Horizon.

As a result it just blocked my whole queue and nothing happened with queue messages accumulating.

./artisan horizon:forget --all didn't solve anything because all my messages were not failed but pending.

The solution I found was to clear all pending jobs and to change the default scout job:

<?php

// app/Jobs/MakeSearchableWithFailure.php

namespace App\Jobs;

use Laravel\Scout\Jobs\MakeSearchable;

class MakeSearchableWithFailure extends MakeSearchable
{
    /**
     * The number of times the job may be attempted.
     */
    public int $tries = 1;

    /**
     * The maximum number of unhandled exceptions to allow before failing.
     */
    public int $maxExceptions = 1;

    /**
     * Indicate if the job should be marked as failed on timeout.
     */
    public bool $failOnTimeout = true;

    /**
     * The number of seconds the job can run before timing out.
     */
    public int $timeout = 30;
}

In my AppServiceProvider:

use Laravel\Scout\Scout;

// ...

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // ...

        Scout::makeSearchableUsing(\App\Jobs\MakeSearchableWithFailure::class);

        // ...
    }

Maybe I wrongly configured horizon and scout, but I couldn't find anything in the scout documentation regarding this phenomenon.

I don't think a temporary timeout should block the whole queue.

Steps To Reproduce

Remove the driver credentials in env vars, and trigger a few dozens of scout imports.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions