未验证 提交 5d5cbbe0 编写于 作者: S Samuel Cochran 提交者: Rafael Mendonça França

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]
上级 9029884e
* Ensure mail gem is eager autoloaded when eager load is true to prevent thread deadlocks.
*Samuel Cochran*
## Rails 5.2.0 (April 09, 2018) ##
* Bring back proc with arity of 1 in `ActionMailer::Base.default` proc
......
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册