Eager autoload mail gem when eager load is true (#32808)
* Eager autoload mail gem when eager load is true We had a production issue where our Sidekiq worker threads all became deadlocked while autoloading a file within the mail gem, required via ActionMailer, despite setting our Rails applicaiton to eager load. `Mail.eager_autoload!` exists and works great, ActionMailer just doesn't call it during eager loading. Adding it to the ActionMailer Railtie's eager_load_namespaces takes care of calling `Mail.eager_autoload!` during the `eager_load!` initializer. * 'Mail' isn't defined yet, use before_eager_load instead * Make sure mail is loaded * Move eager load of Mail into ActionMailer.eager_load! [Samuel Cochran + Rafael Mendonça França]
This commit is contained in:
parent
78a9de52dd
commit
4d43b05881
|
@ -1,3 +1,7 @@
|
|||
* Ensure mail gem is eager autoloaded when eager load is true to prevent thread deadlocks.
|
||||
|
||||
*Samuel Cochran*
|
||||
|
||||
* Perform email jobs in `assert_emails`.
|
||||
|
||||
*Gannon McGibbon*
|
||||
|
|
|
@ -52,6 +52,13 @@ module ActionMailer
|
|||
autoload :TestHelper
|
||||
autoload :MessageDelivery
|
||||
autoload :DeliveryJob
|
||||
|
||||
def self.eager_load!
|
||||
super
|
||||
|
||||
require "mail"
|
||||
Mail.eager_autoload!
|
||||
end
|
||||
end
|
||||
|
||||
autoload :Mime, "action_dispatch/http/mime_type"
|
||||
|
|
Loading…
Reference in New Issue