File tree Expand file tree Collapse file tree
sentry-rails/spec/dummy/test_rails_app/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,6 +153,20 @@ def after_initialize!
153153 end
154154
155155 def cleanup!
156+ # Re-initialising the app triggers the active_job.custom_serializers
157+ # initializer which calls add_serializers(app.config.active_job.custom_serializers).
158+ # Under some Rails/Ruby combinations custom_serializers resolves to nil instead
159+ # of the railtie default of [], inserting nil into the global serializers Set.
160+ # Remove it here so it does not outlive this app instance.
161+ # Rails < 8 uses a mattr_accessor _additional_serializers; Rails 8+ uses @serializers.
162+ if defined? ( ::ActiveJob ::Serializers )
163+ if ::ActiveJob ::Serializers . respond_to? ( :_additional_serializers )
164+ ::ActiveJob ::Serializers . _additional_serializers . delete ( nil )
165+ elsif ::ActiveJob ::Serializers . instance_variable_defined? ( :@serializers )
166+ ::ActiveJob ::Serializers . instance_variable_get ( :@serializers ) . delete ( nil )
167+ end
168+ end
169+
156170 ::Rails . application = nil
157171 end
158172
You can’t perform that action at this time.
0 commit comments