laravel / horizon

Dashboard and code-driven configuration for Laravel queues.
https://laravel.com/docs/horizon
MIT License
3.83k stars 643 forks source link

use Bus::batch([new ImportCsv()])->onQueue("a") when ImportCsv Exception horizon Infinite loop #1414

Closed xnzdev closed 4 months ago

xnzdev commented 4 months ago

Horizon Version

5.9

Laravel Version

9.2

PHP Version

8.0

Redis Driver

PhpRedis

Redis Version

5.3

Database Driver & Version

mysql8.0

Description

当 ImportCsv类中发送异常,horizon 执行队列a 陷入无限循环:

  1. Bus::batch()->catch($callback) $callback 捕获不到异常
  2. config/horizon.php中的 tries=>1 未起作用

Steps To Reproduce

$batch = Bus::batch([ new ImportCsv(1, 100), new ImportCsv(101, 200) ])->onQueue("a") // take care ->then(function (Batch $batch) { // done })->catch(function (Batch $batch, Throwable $e) { // can not catch })->finally(function (Batch $batch) { // can not exec here })->dispatch();

example:

class ImportCsv implements ShouldQueue{ .... public function handle(){ logger("something!"); $a = null; $b = $a[0]; // make error } }

driesvints commented 4 months ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

xnzdev commented 4 months ago

runing the 'php artisan queue:work --queue=a ' command is not a problem. Abort operation when an exception occurs (queue:work). but runing the 'php artisan horizon' infinite loop