Fix bug with eager_load in development environment #33118
Fixes the "Development Environment Lockup" bug reported in Issue #30578, and adds test coverage to protect against any similar bug in the future.
The problem occurs when secondary Engines are loaded (the Rails application is the primary Engine). In the case of a default Rails 5.1/5.2 install, the secondary Engine triggering the problem is ActiveStorage - stop loading ActiveStorage and the problem goes away. This is because, for every secondary Engine, a new RouteSet is created. These secondary RouteSets are apparently not used – routes are not added to them (only to the primary RouteSet). In other words, when you have a secondary Engine, then you have an empty RouteSet. But ActionDispatch::Journey::Routes chokes on empty RouteSets. Specifically, the
This bug was apparently introduced in 5b1332b, which calls the routes simulator during the eager_load process.
I think routes simulation should not trigger an exception when there is an empty RouteSet. The most elegant solution seems to be removing the
For the record, the
rails/journey@242817a#diff-6b67d28f40aaad449c12eece8ba7d506R97 explicitly pulled it out as a conditional, so that's the most likely to hold clues about its intent.
Its effect, which this PR changes, is to leave