Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Deekor opened this issue Feb 19, 2024 · 3 comments

Comments

@Deekor
Copy link

Deekor commented Feb 19, 2024

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
Copy link
Contributor

mperham commented Feb 19, 2024

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
Copy link
Author

Deekor commented Feb 19, 2024

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
Copy link
Contributor

mperham commented Feb 19, 2024

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.

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

No branches or pull requests

2 participants