Skip to content
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

[10.x] Fix Queue::push() ignoring job delays #46590

Closed
wants to merge 1 commit into from
Closed

[10.x] Fix Queue::push() ignoring job delays #46590

wants to merge 1 commit into from

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Mar 25, 2023

This PR fixes job delay not working when dispatched like this:

$job = new SomeJob();

$job->delay(now()->addMinute());

Queue::push($job);

The delay() method comes from the Queuable trait, which is on jobs by default. The code above looks like it should work, but it doesn't. This is a pretty annoying problem to deal with, because during development you're likely to use the sync queue connection that doesn't support delays. This means you won't notice that the delay doesn't work until you push your code to production.

In my case I wrote a job that pinged a server, and on failure re-dispatched itself with a 30 second delay. Because the delay didn't work it executed all attempts in a row instantly without any delay. Luckily I made my code stop after 3 attempts, if I didn't have that limit it would have have been stuck in an infinite loop.

Fixes #46568

Revert "fix job delay"

This reverts commit 487cfe8.

fix job delay not working on Queue::push()
@bert-w
Copy link
Contributor

bert-w commented Mar 25, 2023

I created a more generic solution here #46591

@taylorotwell
Copy link
Member

This is not supposed to work. It was never an intended way to queue delayed jobs. The documented way to delay queued jobs is in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Job delay doesn't work unless you use the Dispatchable trait
3 participants