Skip to content

Worker errors in development mode

Rustam Sharshenov edited this page May 4, 2020 · 1 revision

Rails allows to reload code in non-production environments like development. While it is handy for rails server, it does not play nice with Sneakers. If there are workers running in development mode some errors could appear:

On forking:

ERROR: [Exception error="A copy of ExampleConsumer has been removed from the module tree but is still active!"

On code change (e.g. ActiveRecord model):

ERROR: [Exception error="ExampleModel(#70141817546920) expected, got #<ExampleModel id: 123> which is an instance of ExampleModel(#70141820577060)"

In order to make workers more stable in development disable code reloading for Sneakers (or even all rake tasks):

# in config/envorinments/development.rb
Rails.application.configure do
  # ...
  # config.cache_classes = false
  config.cache_classes = File.basename($PROGRAM_NAME) == 'rake'

  # config.eager_load = false
  config.eager_load = File.basename($PROGRAM_NAME) == 'rake'
  # ...
end
Clone this wiki locally