-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
Laravel Version
12.20.0
PHP Version
8.4.10
Database Driver & Version
No response
Description
Each time a call to \Illuminate\Support\Facades\Artisan::call()
is done, it store the signal handler without clearing the old ones.
Steps To Reproduce
class TestBug2 extends \Illuminate\Console\Command implements \Symfony\Component\Console\Command\SignalableCommandInterface
{
/**
* The console command name.
*
* @var string
*/
// phpcs:ignore
protected $signature = 'TestBug2';
/**
* The console command description.
*/
// phpcs:ignore
protected $description = 'TestBug2';
/**
* Execute the console command.
*/
public function handle(): void
{
echo "hello from TestBug2\n";
\Illuminate\Support\Facades\Artisan::call(TestBug3::class);
\Illuminate\Support\Facades\Artisan::call(TestBug3::class);
\Illuminate\Support\Facades\Artisan::call(TestBug3::class);
\Illuminate\Support\Facades\Artisan::call(TestBug3::class);
sleep(20);
}
/** @return int[] */
public function getSubscribedSignals(): array
{
return [SIGINT, SIGTERM, SIGQUIT];
}
public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false
{
\Illuminate\Support\Facades\Log::notice("Command " . get_class($this) . " Kill asked via signal " . $signal . " on " . gethostname());
return false;
}
}
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use Magileads\Database\DB;
use Magileads\Exceptions\UnexpectedException;
use Magileads\Models\IntegrationsEmail\AccountType;
/**
* Class TestBug
*
* @category Console_Command
*/
class TestBug3 extends \Illuminate\Console\Command implements \Symfony\Component\Console\Command\SignalableCommandInterface
{
/**
* The console command name.
*
* @var string
*/
// phpcs:ignore
protected $signature = 'TestBug3';
/**
* The console command description.
*/
// phpcs:ignore
protected $description = 'TestBug3';
/**
* Execute the console command.
*/
public function handle(): void
{
echo "hello from TestBug3\n";
}
/** @return int[] */
public function getSubscribedSignals(): array
{
return [SIGINT, SIGTERM, SIGQUIT];
}
public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false
{
\Illuminate\Support\Facades\Log::notice("Command " . get_class($this) . " Kill asked via signal " . $signal . " on " . gethostname());
return false;
}
}
When doing php artisan testBug2
and doing
kill -3 (pid)
during the sleep(20)
it will generate the following output
hello from TestBug2
hello from TestBug3
hello from TestBug3
hello from TestBug3
hello from TestBug3
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug2 Kill asked via signal 3 on c6168f1b4100
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug3 Kill asked via signal 3 on c6168f1b4100
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug3 Kill asked via signal 3 on c6168f1b4100
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug3 Kill asked via signal 3 on c6168f1b4100
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug3 Kill asked via signal 3 on c6168f1b4100
What I expect :
hello from TestBug2
hello from TestBug3
hello from TestBug3
hello from TestBug3
hello from TestBug3
[2025-07-21 11:16:36] development.NOTICE: Command App\Console\Commands\TestBug2 Kill asked via signal 3 on c6168f1b4100
Which means the class Symfony\Component\Console\SignalRegistry\SignalRegistry
is filling for each call to Artisan::call, the array $this->signalHandlers
I'm scheduling console commands using queues, so the worker is calling a lot of time Artisan::call
, so it will use more and more memory to fill the array signalHandlers, and when sending a signal, it will generate X lines of notice "Kill asked", X being the number of time the schedule have been called
Metadata
Metadata
Assignees
Labels
No labels