Last active
August 29, 2015 14:04
-
-
Save kares/b08842beb8c34ee6900a to your computer and use it in GitHub Desktop.
ActionController::Live::Response partial <code>process</code> that happens on every "live" request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| error = nil | |
| # This processes the action in a child thread. It lets us return the | |
| # response code and headers back up the rack stack, and still process | |
| # the body in parallel with sending data to the client | |
| Thread.new { | |
| begin | |
| super(name) | |
| rescue => e | |
| if @_response.committed? | |
| begin | |
| complete = ActionView::Base.streaming_completion_on_exception | |
| @_response.stream.write(complete) if request.format == :html | |
| @_response.stream.call_on_error | |
| ensure | |
| @_response.stream.close | |
| end | |
| else | |
| error = e | |
| end | |
| ensure | |
| @_response.commit! | |
| end | |
| } | |
| @_response.await_commit | |
| raise error if error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment