Skip to content

Conversation

@jobvink
Copy link
Contributor

@jobvink jobvink commented Nov 12, 2025

Fix: Pass job delay to pushRaw in push method

Problem

When dispatching jobs using the push() method, the delay property from the job object was not being passed to pushRaw(). This meant that jobs with a configured delay would be executed immediately instead of being scheduled for the specified time.

Solution

Updated the push() method to extract the delay property from the job object (if present) and include it in the options array passed to pushRaw(). This ensures that delayed jobs are properly scheduled with their intended execution time.

The implementation now:

  • Checks if the job is an object with a delay property
  • Includes the delay in the options array alongside the job object
  • Maintains consistency with the release() method which already follows this pattern

Changes

  • Modified src/CloudTasksQueue.php lines 135-142
  • Added logic to extract and pass the delay from job objects to pushRaw()

This brings the push() method in line with how delays are handled in the release() method, ensuring consistent behavior across the queue system.

@marickvantuil
Copy link
Member

Thank you!

In what scenario is the delay property missing when a job is dispatched?
If you can add a test for that case, that would be great. If not, no worries, an example is also fine and I can write the test myself.

@marickvantuil marickvantuil added the safe-to-test Pull request has access to workflow secrets to run tests label Nov 13, 2025
@github-actions github-actions bot removed the safe-to-test Pull request has access to workflow secrets to run tests label Nov 14, 2025
@jobvink
Copy link
Contributor Author

jobvink commented Nov 14, 2025

Thank you!

In what scenario is the delay property missing when a job is dispatched? If you can add a test for that case, that would be great. If not, no worries, an example is also fine and I can write the test myself.

Thank you for your reply. We were noticing that delays were not working for Bus::batch

Our code looks something like this, and it was dispatching all jobs immediately.

$jobs = [];
for ($page = 1; $page <= $totalPages; $page++) {
    $jobs[] = new DownloadPage($page)->delay(now()->addSeconds($page * 30));
}
$batch = Bus::batch($jobs)

I tried to add a test for this scenario. Please let me know your thoughts.

@marickvantuil marickvantuil added the safe-to-test Pull request has access to workflow secrets to run tests label Nov 14, 2025
@marickvantuil marickvantuil merged commit d8298b6 into stackkit:master Nov 14, 2025
75 of 113 checks passed
@marickvantuil
Copy link
Member

Thank you! Tagged this in v5.0.3

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

Labels

safe-to-test Pull request has access to workflow secrets to run tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants