Skip to content

Commit

Permalink
Merge pull request #611 from bugsnag/supress-frozen-middleware-error
Browse files Browse the repository at this point in the history
Convert frozen middleware error into a warning in the Rails integration
  • Loading branch information
imjoehaines committed Jul 27, 2020
2 parents a893ea6 + a530de7 commit 1d5e201
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,19 @@ class Railtie < ::Rails::Railtie

initializer "bugsnag.use_rack_middleware" do |app|
begin
app.config.middleware.insert_after ActionDispatch::DebugExceptions, Bugsnag::Rack
rescue
app.config.middleware.use Bugsnag::Rack
begin
app.config.middleware.insert_after ActionDispatch::DebugExceptions, Bugsnag::Rack
rescue
app.config.middleware.use Bugsnag::Rack
end
rescue FrozenError
# This can happen when running RSpec if there is a crash after Rails has
# started booting but before we've added our middleware. If we don't ignore
# this error then the stacktrace blames Bugsnag, which isn't accurate as
# the middleware will only be frozen if an earlier error occurs
# See this comment for more info:
# https://github.com/thoughtbot/factory_bot_rails/issues/303#issuecomment-434560625
Bugsnag.configuration.warn("Unable to add Bugsnag::Rack middleware as the middleware stack is frozen")
end
end

Expand Down

0 comments on commit 1d5e201

Please sign in to comment.