0

After upgrade to Rails 6 the initializers/sidekiq.rb is causing deprecation warnings about class autoloading. As a workaround I thought I could wrap the contents of Sidekiq.configure_server in Rails.application.config.after_initialize. But after I do that, the job processor won't process the jobs anymore. This is the part that is causing error:

if Rails.env.development?
  Sidekiq.options[:reloader] = proc do |&block|
    ActionDispatch::Reloader.cleanup!
    ActionDispatch::Reloader.prepare!
    block.call
  end
end

> NoMethodError: undefined method `cleanup!' for ActionDispatch::Reloader:Class

If I move that block around and just wrap everything else, it seemingly works. But I'm not sure I'm not causing more problems than I'm solving. Or perhaps there is a better way to solve the constant autoloading problem in Sidekiq initializer? Seeing that it is meant to use with Rails, surely there should be a simpler way to handle this.

0

1 Answer 1

2

I am not familiar with configuring sidekiq at all but ActionDispatch::Reloader::cleanup! and ::prepare! were removed in rails 5.1

According to the deprecation warning that would have been present in 5.0 (Source) it appears these were replaced with Rails.application.reloader.reload! and Rails.application.reloader.prepare! respectively.

Additionally the warning for cleanup! would have stated something like:

DEPRECATION WARNING: ActionDispatch::Reloader.cleanup is deprecated use Rails.application.reloader.reload! instead of cleanup + prepare

As suggested by the warning reload! already calls prepare!, so does changing your current code to this work?

if Rails.env.development?
  Sidekiq.options[:reloader] = proc do |&block|
    Rails.application.reloader.reload!
    block.call
  end
end
1
  • Thanks for the tip on deprecation/removal. Apparently the code was not running at all. For some reason it started running when wrapped in a block. I just removed it, and reloading still seems fine.
    – jva
    Commented Jul 17 at 9:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.