lib/sentry/rails/background_worker.rb in sentry-rails-5.5.0 vs lib/sentry/rails/background_worker.rb in sentry-rails-5.6.0
- old
+ new
@@ -1,10 +1,13 @@
module Sentry
class BackgroundWorker
def _perform(&block)
block.call
ensure
- # make sure the background worker returns AR connection if it accidentally acquire one during serialization
- ActiveRecord::Base.connection_pool.release_connection
+ # 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.release_connection
+ end
end
end
end