Skip to content

error when there weren't any messages in queue and command started with --max-time #542

Closed
@oprudkyi

Description

@oprudkyi
  • Laravel/Lumen version: 10.x
  • RabbitMQ version: 3.11.13
  • Package version: v13.3.0

Describe the bug

fails when consume/work ends without any processed messages - --stop-when-empty, --max-time=10 etc

Steps To Reproduce

run on empty queue

artisan rabbitmq:consume --stop-when-empty

Current behavior

error

  INFO  Processing jobs from the [app-general] queue.  

[2023-05-30 00:14:13] local.ERROR: Typed property VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue::$currentJob must not be accessed before initialization {"exception":"[object] (Error(code: 0): Typed property VladimirYuldashev\\LaravelQueueRabbitMQ\\Queue\\RabbitMQQueue::$currentJob must not be accessed before initialization at /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php:580)
[stacktrace]
#0 /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/Connectors/RabbitMQConnector.php(44): VladimirYuldashev\\LaravelQueueRabbitMQ\\Queue\\RabbitMQQueue->close()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(421): VladimirYuldashev\\LaravelQueueRabbitMQ\\Queue\\Connectors\\RabbitMQConnector::VladimirYuldashev\\LaravelQueueRabbitMQ\\Queue\\Connectors\\{closure}(Object(Illuminate\\Queue\\Events\\WorkerStopping))
#2 /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Queue\\\\Events\\\\WorkerStopping', Array)
#3 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(754): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Queue\\\\Events\\\\WorkerStopping')
#4 /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php(208): Illuminate\\Queue\\Worker->stop(0, Object(Illuminate\\Queue\\WorkerOptions))
#5 /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php(177): VladimirYuldashev\\LaravelQueueRabbitMQ\\Consumer->stop(0, Object(Illuminate\\Queue\\WorkerOptions))
#6 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(136): VladimirYuldashev\\LaravelQueueRabbitMQ\\Consumer->daemon('rabbitmq', 'app-general', Object(Illuminate\\Queue\\WorkerOptions))
#7 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(119): Illuminate\\Queue\\Console\\WorkCommand->runWorker('rabbitmq', 'app-general')
#8 /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Console/ConsumeCommand.php(48): Illuminate\\Queue\\Console\\WorkCommand->handle()
#9 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): VladimirYuldashev\\LaravelQueueRabbitMQ\\Console\\ConsumeCommand->handle()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#12 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#13 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#14 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(208): Illuminate\\Container\\Container->call(Array)
#15 /var/www/vendor/symfony/console/Command/Command.php(312): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#16 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(177): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#17 /var/www/vendor/symfony/console/Application.php(1040): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 /var/www/vendor/symfony/console/Application.php(314): Symfony\\Component\\Console\\Application->doRunCommand(Object(VladimirYuldashev\\LaravelQueueRabbitMQ\\Console\\ConsumeCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 /var/www/vendor/symfony/console/Application.php(168): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /var/www/app/Console/Kernel.php(25): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /var/www/artisan(35): App\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 {main}
"} 

   Error 

  Typed property VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue::$currentJob must not be accessed before initialization

  at vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php:580
    576▕      * @throws Exception
    577▕      */
    578▕     public function close(): void
    579▕     {
  ➜ 580▕         if (! $this->currentJob->isDeletedOrReleased()) {
    581▕             $this->reject($this->currentJob, true);
    582▕         }
    583▕ 
    584▕         try {

      +21 vendor frames 

  22  app/Console/Kernel.php:25
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  23  artisan:35
      App\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Expected behavior

no error

Additional context

Add any other context about the problem or describe the use-case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions