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

Exceptions raised during streaming via ActionController::Live are not caught #1258

Open
shnikola opened this issue Jan 24, 2024 · 1 comment

Comments

@shnikola
Copy link

When in a controller which has ActionController::Live included, exceptions are not sent to Airbrake if they happen during the streaming.

For example, this will correctly notify an exception:

class TestController
  include ActionController::Live

  def streaming
    raise "TEST"
  end
end

On the other hand, this will be ignored by Airbrake:

  def streaming
    response.stream.write("Hello\n")
    raise "TEST"
  end

This possibly has something to with the stream being run in a separate thread and the response already being commited when the exception happens.

I see there is a similar issue that has been resolved but I could not find any more info on it.

@shnikola
Copy link
Author

My current workaround for this is capturing the exceptions myself and manually sending them to Airbrake:

  def streaming
    response.stream.write("Hello\n")
    raise "TEST"
  rescue => e
    notify_airbrake(e)
  ensure
    response.stream.close
  end

This works, but it skips all the Rails exception handling code, so e.g. the error doesn't get added to the logs. It would be great if Airbrake could make this work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant