Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let Rails eager load the application #1867

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

fxn
Copy link

@fxn fxn commented Apr 15, 2023

I may be missing something, so please consider this patch a conversation starter :).

When Rails.application.config.eager_load is true, Rails already executes

ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
Rails.application.config.eager_load_namespaces.each(&:eager_load!)

among other things.

You can check this in main, 7.0, 6.1, 6.0, ..., all the way back to 3.0 (slightly different by then).

Therefore, if config.eager_load is true, not only is this task doing unnecessary work, but it could potentially trigger code execution twice, since idempotence is not a requirement of those hooks.

For example, if you test an application with these settings:

config.before_eager_load { p :CALLED }
config.rake_eager_load = true # config.eager_load is overridden with this one for Rake tasks

you'll see :CALLED twice.

So, I suspect this might be a leftover from old Resque versions and can be entirely removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant