Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert frozen middleware error into a warning in the Rails integration #611

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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