contribsys / faktory_worker_ruby

Faktory worker for Ruby
GNU Lesser General Public License v3.0
214 stars 31 forks source link

unique_for throwing Faktory::CommandError: json: unsupported value: floating point number #85

Open Deekor opened 6 months ago

Deekor commented 6 months ago

gem version 2.0.0

We recently added faktory_options custom: { unique_for: 1.hour.to_i } to one of our workers and we are now getting: Faktory::CommandError: json: unsupported value: floating point number when trying to enqueue a job.

We've used the exact line faktory_options custom: { unique_for: 1.hour.to_i } in several other workers without an issue so this is perplexing.

image

module OurWorkersModule
  class OurWorker
      include Faktory::Job

      faktory_options custom: { unique_for: 1.hour.to_i }
      faktory_options queue: 'ourqueue'

....
mperham commented 6 months ago
irb(main):011* class OurWorker
irb(main):012*       include Faktory::Job
irb(main):013*   
irb(main):014*   faktory_options custom: { unique_for: 3600.to_i }
irb(main):015> end
=> {"retry"=>25, "queue"=>"default", "custom"=>{:unique_for=>3600}}
irb(main):016> OurWorker.perform_async
=> "c962b9985b81d507535e143c"

Works for me.

Deekor commented 6 months ago

You're right. It seems to be isolated to json we are passing into the worker as a param. Ive double checked the json is valid but there seems to be some sort of issue going from json -> faktory redis -> back to json through the gem. Passing the json as a string param and running ruby JSON.parse(param) in the worker perform resolved the issue.

mperham commented 6 months ago

If you can narrow down that JSON we can try to make it better. JSON has some crazy limitations due to JS’s weird 53-bit floats.