Skip to content

Commit

Permalink
Merge new attributes if existing attributes, fixes #5090
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Dec 9, 2021
1 parent 615393d commit c92a521
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -24,6 +24,7 @@ SomeJob.set("sync": true).perform_async(args...) # will run via perform_inline
```
bin/rails generate sidekiq:job ProcessOrderJob
```
- Fix job retries losing CurrentAttributes [#5090]

6.3.1
---------
Expand Down
7 changes: 6 additions & 1 deletion lib/sidekiq/middleware/current_attributes.rb
Expand Up @@ -20,7 +20,12 @@ def initialize(cattr)
end

def call(_, job, _, _)
job["cattr"] = @klass.attributes
attrs = @klass.attributes
if job.has_key?("cattr")
job["cattr"].merge!(attrs)
else
job["cattr"] = attrs
end
yield
end
end
Expand Down

0 comments on commit c92a521

Please sign in to comment.