thoughtbot / griddler

Simplify receiving email in Rails (deprecated)
http://griddler.io/
MIT License
1.38k stars 199 forks source link

EmailServiceAdapterNotFound on subsequent e-mails #295

Closed bodrovis closed 2 years ago

bodrovis commented 7 years ago

Hello. I am using Griddler with Rails 5 (on Heroku) and a quite strange happens to me: when the first e-mail arrives, everything is okay and it gets processed. But processing all subsequent e-mails fails with Griddler::Errors::EmailServiceAdapterNotFound. From the logs I am able to see the arrived e-mail. The stack trace is displayed below.

Gemfile:

gem 'griddler-sparkpost'
gem 'griddler'

Initializer:

Griddler.configure do |config|
  config.processor_class = EmailProcessor
  config.email_class = Griddler::Email
  config.processor_method = :process
  config.reply_delimiter = '-- REPLY ABOVE THIS LINE --'
  config.email_service = :sparkpost
end

Stack trace:

2017-10-16T12:55:10.178745+00:00 app[web.1]: I, [2017-10-16T12:55:10.178666 #6]  INFO -- : [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)

2017-10-16T12:55:10.181065+00:00 app[web.1]: F, [2017-10-16T12:55:10.180995 #6] FATAL -- : [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] Griddler::Errors::EmailServiceAdapterNotFound (Griddler::Errors::EmailServiceAdapterNotFound):
2017-10-16T12:55:10.180996+00:00 app[web.1]: F, [2017-10-16T12:55:10.180920 #6] FATAL -- : [4c0001e2-fece-4bcb-8b8a-cc2987a0735b]
2017-10-16T12:55:10.181121+00:00 app[web.1]: F, [2017-10-16T12:55:10.181068 #6] FATAL -- : [4c0001e2-fece-4bcb-8b8a-cc2987a0735b]
2017-10-16T12:55:10.181222+00:00 app[web.1]: F, [2017-10-16T12:55:10.181152 #6] FATAL -- : [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/griddler-1.4.0/lib/griddler/configuration.rb:55:in `email_service'
2017-10-16T12:55:10.181226+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/griddler-1.4.0/app/controllers/griddler/emails_controller.rb:12:in `email_service'
2017-10-16T12:55:10.181227+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/griddler-1.4.0/app/controllers/griddler/emails_controller.rb:17:in `normalized_params'
2017-10-16T12:55:10.181228+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/griddler-1.4.0/app/controllers/griddler/emails_controller.rb:3:in `create'
2017-10-16T12:55:10.181228+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
2017-10-16T12:55:10.181229+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:186:in `process_action'
2017-10-16T12:55:10.181230+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/rendering.rb:30:in `process_action'

2017-10-16T12:55:10.181230+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
2017-10-16T12:55:10.181231+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:131:in `run_callbacks'
2017-10-16T12:55:10.181232+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:19:in `process_action'
2017-10-16T12:55:10.181233+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/rescue.rb:20:in `process_action'
2017-10-16T12:55:10.181234+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
2017-10-16T12:55:10.181235+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `block in instrument'
2017-10-16T12:55:10.181236+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
2017-10-16T12:55:10.181237+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `instrument'
2017-10-16T12:55:10.181237+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
2017-10-16T12:55:10.181239+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
2017-10-16T12:55:10.181240+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/railties/controller_runtime.rb:22:in `process_action'
2017-10-16T12:55:10.181240+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:124:in `process'
2017-10-16T12:55:10.181241+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionview-5.1.4/lib/action_view/rendering.rb:30:in `process'
2017-10-16T12:55:10.181242+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:189:in `dispatch'
2017-10-16T12:55:10.181242+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:253:in `dispatch'
2017-10-16T12:55:10.181243+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
2017-10-16T12:55:10.181244+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:31:in `serve'
2017-10-16T12:55:10.181244+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:50:in `block in serve'
2017-10-16T12:55:10.181245+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in `each'
2017-10-16T12:55:10.181246+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in `serve'
2017-10-16T12:55:10.181249+00:00 app[web.1]: [4c0001e2-fece-4bcb-8b8a-cc2987a0735b] vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:834:in `call'
bodrovis commented 7 years ago

As a temporary solution, I've added a before_action for the Griddler::EmailsController:

  def register_service!
    Griddler.adapter_registry.register(:sparkpost, Griddler::Sparkpost::Adapter)
    Griddler.configuration.email_service = :sparkpost
  end

It works. Seems like the adapter becomes unregistered for some reason.