Hasty Briefsbeta

Bilingual

How to Safely Change the Argument Signature of a Sidekiq Job

a day ago
  • Upgrading Sidekiq to 6.4 triggered warnings about unsafe job arguments (non‑JSON‑safe hashes with symbol keys and Time objects).
  • Using `Sidekiq.strict_args!` in the initializer converts warnings into errors to enforce best practices.
  • Best practice is to pass only scalar values (strings, numbers, booleans, nil) as positional arguments, not complex objects like hashes.
  • To change a job’s argument signature safely, create a duplicate job class with the new signature (e.g., `RequestLogWorker2`).
  • Deploy the new job class and migrate all callers to use it; the old job backlog will eventually clear.
  • Once the old job backlog is empty, rename the new class back to the original name (e.g., `RequestLogWorker`) and add an alias (`RequestLogWorker2 = RequestLogWorker`) to handle any remaining queued jobs.
  • After the alias backlog clears, remove the alias—the migration is complete and the job signature is safely changed.