diff options
author | Geoff Lee <geoff.lee@lendesk.com> | 2018-04-03 19:54:27 -0700 |
---|---|---|
committer | Geoff Lee <geoff.lee@lendesk.com> | 2018-04-03 19:54:27 -0700 |
commit | 0ac64470ea3dd39e7285ecb971b5995fb94eb2c2 (patch) | |
tree | 4a9beeef7cca628cd3847c86664c035a941d45b3 /railties/lib/rails | |
parent | a07d0680787ced3c04b362fa7a238c918211ac70 (diff) | |
download | rails-0ac64470ea3dd39e7285ecb971b5995fb94eb2c2.tar.gz rails-0ac64470ea3dd39e7285ecb971b5995fb94eb2c2.tar.bz2 rails-0ac64470ea3dd39e7285ecb971b5995fb94eb2c2.zip |
Stop mutating body response
If @app.call returns an object that is saved (for e.g., in a constant), the mutation results in a continuing cycle of wrapping the body in Rack::BodyProxy, eventually leading to SystemStackError
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On branch fix-return-response-mutation-rack-logger - Tue 3 Apr 2018 19:54:28 PDT by Geoff Lee <geoff.lee@lendesk.com>
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/rack/logger.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/lib/rails/rack/logger.rb b/railties/lib/rails/rack/logger.rb index ec5212ee76..4ea7e40319 100644 --- a/railties/lib/rails/rack/logger.rb +++ b/railties/lib/rails/rack/logger.rb @@ -35,9 +35,9 @@ module Rails instrumenter = ActiveSupport::Notifications.instrumenter instrumenter.start "request.action_dispatch", request: request logger.info { started_request_message(request) } - resp = @app.call(env) - resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) } - resp + status, headers, body = @app.call(env) + body = ::Rack::BodyProxy.new(body) { finish(request) } + [status, headers, body] rescue Exception finish(request) raise |