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

Fix Rails 7.1 regression: Delayed::JobWrapper not defined #30

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

smudge
Copy link
Member

@smudge smudge commented Oct 19, 2023

This fixes #29, which can be reproduced on new Rails 7.1.1 apps in development.

The issue stems from the fact that Rails no longer loads ActiveJob at all until the first ActiveJob::Base class is referenced, but we defined our Delayed::JobWrapper class in a file that only loads after ActiveJob loads. This means that you can enqueue an ActiveJob, but the first time delayed:work tries to deserialize the handler, it encounters the Delayed::JobWrapper constant before it encounters its first ActiveJob::Base class.

The fix is to pull Delayed::JobWrapper out into its own file in lib/ and load it when lib/delayed.rb loads. The class itself has no dependencies outside of activesupport (delegate_missing_to) so this is safe enough to do.

/no-platform

Copy link

@AndrewSwerlick AndrewSwerlick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain lgtm

@smudge smudge merged commit 342acb9 into Betterment:main Oct 19, 2023
21 checks passed
@smudge smudge deleted the rails-71-fix branch October 19, 2023 18:26
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.

Job failed to load: undefined class/module Delayed::JobWrapper.
2 participants