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.
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 ourDelayed::JobWrapper
class in a file that only loads after ActiveJob loads. This means that you can enqueue an ActiveJob, but the first timedelayed:work
tries to deserialize the handler, it encounters theDelayed::JobWrapper
constant before it encounters its firstActiveJob::Base
class.The fix is to pull
Delayed::JobWrapper
out into its own file inlib/
and load it whenlib/delayed.rb
loads. The class itself has no dependencies outside ofactivesupport
(delegate_missing_to
) so this is safe enough to do./no-platform