Skip to content

Commit b6bf6a9

Browse files
authored
Wrap BankApiService in reloader callback (#3250)
#3111 This fixes this deprecation warning which is an error in Rails 7 ``` DEPRECATION WARNING: Initialization autoloaded the constants Util and BankApiService. Being able to do this is deprecated. Autoloading during initialization is going to be an error condition in future versions of Rails. Reloading does not reboot the application, and therefore code executed during initialization does not run again. So, if you reload Util, for example, the expected changes won't be reflected in that stale Module object. These autoloaded constants have been unloaded. In order to autoload safely at boot time, please wrap your code in a reloader callback this way: Rails.application.reloader.to_prepare do # Autoload classes and modules needed at boot time here. end That block runs when the application boots, and every time there is a reload. For historical reasons, it may run twice, so it has to be idempotent. Check the "Autoloading and Reloading Constants" guide to learn more about how Rails autoloads and reloads. (called from <top (required)> at /usr/src/app/config/environment.rb:7) ```
1 parent 6aa2969 commit b6bf6a9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

config/initializers/airbrake.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@
8181
notice.ignore! if rand(1..10) <= 9
8282
end
8383

84-
ignorable_errors = [SignalException, Sidekiq::Shutdown, Plaid::PlaidAPIError, ActiveRecord::ConnectionTimeoutError, ::BankApiService::UnauthorizedError]
8584

86-
Airbrake.add_filter do |notice|
87-
next unless ignorable_errors.include?(notice.stash[:exception].class)
85+
Rails.application.reloader.to_prepare do
86+
ignorable_errors = [SignalException, Sidekiq::Shutdown, Plaid::PlaidAPIError, ActiveRecord::ConnectionTimeoutError, ::BankApiService::UnauthorizedError]
87+
88+
Airbrake.add_filter do |notice|
89+
next unless ignorable_errors.include?(notice.stash[:exception].class)
8890

89-
notice.ignore!
91+
notice.ignore!
92+
end
9093
end

0 commit comments

Comments
 (0)