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

Job delay doesn't work unless you use the Dispatchable trait #46568

Closed
SjorsO opened this issue Mar 24, 2023 · 2 comments
Closed

Job delay doesn't work unless you use the Dispatchable trait #46568

SjorsO opened this issue Mar 24, 2023 · 2 comments

Comments

@SjorsO
Copy link
Contributor

SjorsO commented Mar 24, 2023

  • Laravel Version: v9.36.4
  • PHP Version: 8.1
  • Database Driver & Version: not relevant

Description:

Delaying a job like this works:

SomeJob::dispatch()->delay(now()->addMinute());

But this doesn't work, it ignores the delay and instantly processes the job:

$job = new SomeJob();

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

Queue::push($job);

As far as I can tell, this happens because Queue::push() doesn't pass down the $job->delay to the EnqueueUsing method.

Steps To Reproduce:

  1. Make sure your queue connection supports delay (so anything except sync)
  2. Make a job that implements ShouldQueue
  3. Dispatch the job with a delay like shown above
  4. Watch the job get processed instantly without a delay
@SjorsO SjorsO changed the title [10.x] Job delay doesn't work unless you use the Dispatchable trait Job delay doesn't work unless you use the Dispatchable trait Mar 24, 2023
@github-actions
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@taylorotwell
Copy link
Member

I think this is pretty much expected behavior. You are bypassing the Bus which provides all of that stuff. You would need to use Queue::later if you want to hit the queue directly.

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

Successfully merging a pull request may close this issue.

3 participants