Skip to content

Commit

Permalink
Fix instance level after_unlock callback (#737)
Browse files Browse the repository at this point in the history
BACKGROUND -------------------------------------------------------------

#707 introduced a regression where the instance level `after_unlock`
callback is no longer being called. This was due to the change of using
`item[CLASS]` instead of `worker_class` to set `job_class` in
`SidekiqUniqueJobs::Middelware#call`. `item[CLASS]` is a string, where
as `worker_class` can be either an instance, or the class itself. For the
instance level `after_unlock` to work, we need `job_class` to be an
instance of the worker.

This fixes the issue by switching back to setting `job_class` to
`worker_class`

CHANGELOG --------------------------------------------------------------

- Use worker_class for self.job_class in Middleware#call

Co-authored-by: Mikael Henriksson <[email protected]>
  • Loading branch information
adamcreekroad and mhenrixon authored Dec 3, 2022
1 parent 60fdbf7 commit 6f244a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def call(worker_class, item, queue, redis_pool = nil)
@item = item
@queue = queue
@redis_pool = redis_pool
self.job_class = item[CLASS]
self.job_class = worker_class
return yield if unique_disabled?

SidekiqUniqueJobs::Job.prepare(item) unless item[LOCK_DIGEST]
Expand Down

0 comments on commit 6f244a2

Please sign in to comment.