Skip to content

Commit e8103e4

Browse files
committed
Silence _perform method redefinition warning
I'd like to get rid of this noisy warning: ```shell sentry-rails-5.26.0/lib/sentry/rails/background_worker.rb:5: warning: method redefined; discarding old _perform sentry-ruby-5.26.0/lib/sentry/background_worker.rb:74: warning: previous definition of _perform was here ``` #skip-changelog # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Date: Sun Aug 24 01:04:29 2025 +0400 # # On branch silence-perform-method-redefinition-warning # Changes to be committed: # modified: lib/sentry/rails/background_worker.rb #
1 parent 337a4ca commit e8103e4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

sentry-rails/lib/sentry/rails/background_worker.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
module Sentry
44
class BackgroundWorker
5-
def _perform(&block)
6-
block.call
7-
ensure
8-
# some applications have partial or even no AR connection
9-
if ActiveRecord::Base.connected?
10-
# make sure the background worker returns AR connection if it accidentally acquire one during serialization
11-
ActiveRecord::Base.connection_pool.release_connection
5+
module ActiveRecordConnectionPatch
6+
def _perform(&block)
7+
super(&block)
8+
ensure
9+
# some applications have partial or even no AR connection
10+
if ActiveRecord::Base.connected?
11+
# make sure the background worker returns AR connection if it accidentally acquire one during serialization
12+
ActiveRecord::Base.connection_pool.release_connection
13+
end
1214
end
1315
end
1416
end
1517
end
18+
19+
Sentry::BackgroundWorker.prepend(Sentry::BackgroundWorker::ActiveRecordConnectionPatch)

0 commit comments

Comments
 (0)