Skip to content

Commit

Permalink
chore: resolve sidekiq json-unsafe warning
Browse files Browse the repository at this point in the history
Sidekiq 6.4 has started to log warnings
(sidekiq/sidekiq#5071) if the job arguments are
not strictly JSON-safe i.e. serializing to JSON and deserializing from
JSON yield consistent outputs. To what it means, we cannot use a hash
with symbol keys since doing the JSON rountrip will change them all to
string keys.

This fix will do the JSON round trip for the job argument beforehand so
Sidekiq won't complain it (and break it starting version 7.0)
  • Loading branch information
QQism committed Feb 13, 2022
1 parent a3c098b commit 23fc9c1
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -7,7 +7,7 @@ def initialize(serializer:)
end

def call(klass, record)
klass.perform_async(record.serialize(serializer).to_h)
klass.perform_async(JSON.parse(JSON.dump(record.serialize(serializer).to_h)))
end

def verify(subscriber)
Expand Down

0 comments on commit 23fc9c1

Please sign in to comment.