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

Handle throwing in controller action in log subscriber #41223

Merged
merged 1 commit into from Jan 24, 2021

Commits on Jan 24, 2021

  1. Handle throwing in controller action in log subscriber

    When throw was used in a controller action, and there is matching catch
    around the request in a Rack middleware, then :exception won't be
    present in the event payload.
    
    This is because ActiveSupport::Notifications::Instrumenter.instrument
    sets :exception in a rescue handler, but rescue is never called in a
    throw/catch scenario:
    
      catch(:halt) do
        begin
          throw :halt
        rescue Exception => e
          puts "rescue" # never reached
        ensure
          puts "ensure"
        end
      end
    
    Missing :exception was actually handled prior to Rails 6.1.0, but an
    optimization updated the code to assume this was present. So this can be
    considered a regression fix.
    janko committed Jan 24, 2021
    Copy the full SHA
    53adf53 View commit details
    Browse the repository at this point in the history