1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/application
Xavier Noria 112077c255 inject Rack::Lock if config.eager_load is false
If code is not eager loaded constants are loaded on demand. Constant
autoloading is not thread-safe, so if eager loading is not enabled
multi-threading should not be allowed.

This showed up in certain Capybara scenarios: Most Capybara drivers
other than Rack::Test need a web server. In particular, drivers for
JavaScript support. Capybara launches WEBrick in its own thread for
those but that per se is fine, because the spec thread and the server
thread are coordinated.

Problem comes if the page being served in the spec makes Ajax calls.
Those may hit WEBrick in parallel, and since WEBrick is multi-threaded
and allow_concurrency? returns true in the test environment before
this patch, threads are spawned to serve those parallel requests. On
the other hand, since eager_load is false by default in the test
environment, constants are not preloaded.

So the suite is autoloading constants in a multi-threaded set. That's
a receipt for paracetamol. The symptom is random obscure errors whose
messages point somehow to constant autoloading.

As a consequence of this fix for allow_concurrency? WEBrick in
Capybara scenarios no longer runs in multi-threaded mode.

Fixes #15089.
2014-09-18 23:04:08 +02:00
..
bootstrap.rb world writable might be a bit too open... 2014-09-05 16:44:41 +02:00
configuration.rb Tell the user which file is missing when config/database.yml was not found 2014-09-10 19:25:01 +09:00
default_middleware_stack.rb inject Rack::Lock if config.eager_load is false 2014-09-18 23:04:08 +02:00
finisher.rb Add configuration to enable mail previews 2014-07-01 14:39:59 +10:00
routes_reloader.rb Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00