Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

The process "'/usr/bin/php8.4' 'artisan' invoke-serialized-closure" exceede d the timeout of 60 seconds in Concurrency::run() #55278

Closed
usmonaliyev99 opened this issue Apr 4, 2025 · 2 comments

Comments

@usmonaliyev99
Copy link

usmonaliyev99 commented Apr 4, 2025

Laravel Version

12.3.0

PHP Version

8.4

Database Driver & Version

No response

Description

I create a command, it command should work from 3am until 23pm.

is_plum_time function returns bool to check time.
It get contracts from database and split them to 3 or 4 part, it create workers array.
Then it gives them to Concurrency::run.

Steps To Reproduce

`

public function handle(): void
{
    while (true) {
        if (! is_plum_time()) {
            sleep(60);

            continue;
        }

        $this->manager();
    }
}

public function manager(): void
{
    $this->info('Manager started work at '.now()->format('Y-m-d H:i:s'));

    $count = 1;
    $workers = [];

    $chunks = ContractCard::query()
        ->select([
            'contract_cards.branch_id',
            'contract_cards.plum_card_id',
            'contracts.id AS contract_id',
            'contracts.client_id',
            'contracts.current_debt',
        ])
        ->join('contracts', 'contracts.id', '=', 'contract_cards.contract_id')
        ->where('contracts.current_debt', '>', Setting::contractMinDebtAmount())
        ->where('contracts.status', ContractStatus::ACTIVE)
        ->where('contract_cards.active', true)
        ->get()
        ->split($count)
        ->toArray();

    foreach ($chunks as $chunk) {
        $workers[] = fn () => WorkerJob::run($chunk);
    }

    $this->info('Workers created: '.count($workers));

    Concurrency::run($workers);
}

`

@usmonaliyev99
Copy link
Author

[previous exception] [object] (Symfony\Component\Process\Exception\ProcessTimedOutException(code: 0): The process "'/usr/bin/php8.4' 'artisan' invoke-serialized-closure" exceeded the timeout of 60 seconds. at /vendor/symfony/process/Process.php:1181)

@rodrigopedra
Copy link
Contributor

The default Concurrency driver is the ProcessDriver, which will convert each task to be run as a Illuminate\Process\PendingProcess, and this has a default timeout of 60 seconds.

/**
* The maximum number of seconds the process may run.
*
* @var int|null
*/
public $timeout = 60;

You can either use the ForkDriver (needs the spatie/fork package to be installed, check the docs for how to use it), or write, and register, a custom driver which increases or removes that timeout.

The relevant code would be your WorkerJob, and from the snippet you posted there will always be only one chunk, as $count = 1 on the beginning is never changed.

But I assume you might have omitted some parts you deemed as irrelevant.

@laravel laravel locked and limited conversation to collaborators Apr 6, 2025
@crynobone crynobone converted this issue into discussion #55295 Apr 6, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants