I saw that https://github.com/laravel/horizon/pull/755 added a way to see if a job is delayed, and until when. Which is a really great enhancement, thanks!
I have a job that uses $this->release($delayInSeconds) to put itself back on the queue. And I can't see the badge, or anything related to the delay, in the UI.
Is that taken into account when showing the delay on the UI? Or is it only when initially dispatching the job with a delay.
Thanks!
Hey there,
Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? We'll help you out and re-open this issue if so.
Thanks!
This is also true for version 4.0.2. Please consider reopening the issue @driesvints.
It seems like Horizon displays the badge when the payload contains the delay key, but the payload is only created the first time the job is pushed to the queue. When a job is being deleted and released to the delayed queue, the payload isn't updated with the delay key.
I understand that deleteAndRelease is part of the Laravel core, so the issue might be a little unrelated to Horizon itself.
@Cannonb4ll can you maybe check into the questions above?
Will do, @mpskovvang can you describe a small replicable case so I can replicate it? Then i'll be able shoot in a PR that fixes this 👏
Sure @Cannonb4ll. Below is probably the simplest replicable case:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class Test implements ShouldQueue
{
use InteractsWithQueue, Queueable;
public $tries = 3;
public function handle()
{
$this->release(60);
}
}
$ php artisan tinker
>>> app(\Illuminate\Contracts\Bus\Dispatcher::class)->dispatch(new \App\Jobs\Test());
Horizon will process the job as expected, and release it back to the queue with a delay. The job will be listed in the Pending jobs but without the badge and the tooltip.
Thanks for having a look. The Delayed badge is a great enhancement! 👍
Alright, I have done some digging. And it seems that using the release() method does not even inject any data into the job that we can use to display the badge when 'releasing' jobs.
I get the feeling that this is deeper than horizon itself, or a missing key from the Job repository.
I have checked my local redis server for the JSON data:
{"id":"276","created_at":"1584691622.9025","queue":"default","updated_at":"1584691622.9025","name":"App\\Jobs\\ReleaseJob","connection":"redis","payload":"{\"uuid\":\"59873e14-23de-4117-aeb3-943860bf6351\",\"displayName\":\"App\\\\Jobs\\\\ReleaseJob\",\"job\":\"Illuminate\\\\Queue\\\\CallQueuedHandler@call\",\"maxTries\":3,\"maxExceptions\":null,\"delay\":null,\"timeout\":null,\"timeoutAt\":null,\"data\":{\"commandName\":\"App\\\\Jobs\\\\ReleaseJob\",\"command\":\"O:19:\\\"App\\\\Jobs\\\\ReleaseJob\\\":9:{s:5:\\\"tries\\\";i:3;s:6:\\\"\\u0000*\\u0000job\\\";N;s:10:\\\"connection\\\";N;s:5:\\\"queue\\\";N;s:15:\\\"chainConnection\\\";N;s:10:\\\"chainQueue\\\";N;s:5:\\\"delay\\\";N;s:10:\\\"middleware\\\";a:0:{}s:7:\\\"chained\\\";a:0:{}}\"},\"id\":\"276\",\"attempts\":0,\"type\":\"job\",\"tags\":[],\"pushedAt\":\"1584691622.9015\"}","status":"pending"}
In this, I am also unable to find any data related to the release option.
@themsaid Is this known with you? For me it sounds to a missing piece of data from the queue from the Laravel framework itself. Would love to get some help on this one.
Hey,
Yes releasing with a delay is not the same as delaying the job. A delayed job never ran, a released job is already delayed by default so even without setting a delay it's considered delayed.
Thank you for clarifying. TIL 🏄♂️
@mpskovvang I am sorry I was not able to help you on this one, but as Mohammed explained it is intended behaviour.
I did expect this conclusion, and I do understand the decision behind although an indicator for a released job would have been helpful.
Anyway, thanks for your effort!