Skip to content

Commit b0b1eb5

Browse files
authored
Eager load the Rails default controllers used in production (rails#50558)
Since those controller can be used in production we need to eager load them to better copy-on-write and avoid tread-safety issues.
1 parent 826a3d1 commit b0b1eb5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

railties/lib/rails.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ module Rails
2727
extend ActiveSupport::Autoload
2828
extend ActiveSupport::Benchmarkable
2929

30-
autoload :HealthController
3130
autoload :Info
3231
autoload :InfoController
3332
autoload :MailersController
34-
autoload :PwaController
3533
autoload :WelcomeController
3634

35+
eager_autoload do
36+
autoload :HealthController
37+
autoload :PwaController
38+
end
39+
3740
class << self
3841
@application = @app_class = nil
3942

railties/lib/rails/application/finisher.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ module Finisher
7878
if config.eager_load
7979
ActiveSupport.run_load_hooks(:before_eager_load, self)
8080
Zeitwerk::Loader.eager_load_all
81+
Rails.eager_load!
8182
config.eager_load_namespaces.each(&:eager_load!)
8283

8384
if config.reloading_enabled?

0 commit comments

Comments
 (0)