Skip to content

Conversation

toydestroyer
Copy link
Contributor

👋

We've noticed inconsistent behavior between jobs enqueued normally and those enqueued in batches using ActiveJob.perform_all_later. When using batch enqueue, the job attribute scheduled_at is missing (unless wait or wait_until is used).

Besides being inconsistent, this causes a problem with Mission Control, as you can't view the details of a finished job due to this line: https://github.com/rails/mission_control-jobs/blob/7ac38357e33778099b8b76b5476bf36ad3b53bf2/lib/active_job/job_proxy.rb#L30, which throws the following exception:

can't convert NilClass into an exact number (TypeError)

      minus_without_duration(other)

This PR makes the behavior consistent and adds tests.

@toydestroyer toydestroyer marked this pull request as ready for review September 8, 2025 11:44
Copy link
Member

@rosa rosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'd do the change differently, though, since that line looks out of place there. I'd add it on attributes_from_active_job, like this:

diff --git a/app/models/solid_queue/job.rb b/app/models/solid_queue/job.rb
index 6a6a6fa..37893c0 100644
--- a/app/models/solid_queue/job.rb
+++ b/app/models/solid_queue/job.rb
@@ -58,7 +58,7 @@ def attributes_from_active_job(active_job)
             queue_name: active_job.queue_name || DEFAULT_QUEUE_NAME,
             active_job_id: active_job.job_id,
             priority: active_job.priority || DEFAULT_PRIORITY,
-            scheduled_at: active_job.scheduled_at,
+            scheduled_at: active_job.scheduled_at || Time.current,
             class_name: active_job.class.name,
             arguments: active_job.serialize,
             concurrency_key: active_job.concurrency_key

It's consistent with other attributes where a default value is provided.

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.

2 participants