lib/sentry/rails/background_worker.rb in sentry-rails-5.2.1 vs lib/sentry/rails/background_worker.rb in sentry-rails-5.3.0

- old
+ new

@@ -1,9 +1,14 @@ module Sentry class BackgroundWorker def _perform(&block) - # make sure the background worker returns AR connection if it accidentally acquire one during serialization - ActiveRecord::Base.connection_pool.with_connection do + # some applications have partial or even no AR connection + if ActiveRecord::Base.connected? + # make sure the background worker returns AR connection if it accidentally acquire one during serialization + ActiveRecord::Base.connection_pool.with_connection do + block.call + end + else block.call end end end end