Commit Graph

17 Commits

Author SHA1 Message Date
KJ Tsanaktsidis
5faeb7007d
Don't pop logger tags in Rails::Rack::Logger until request is finished
At the moment, Rails::Rack::Logger tags the logger (if it's
ActiveSupport::TaggedLogging) for the duration of the @app.call, but
only fires the request.action_dispatch event later, on body close. That
means anything logged in request.action_dispatch handlers won't have the
same tags as the rest of the request.

Fix this by deferring the popping of tags into
finish_request_instrumentation, in the same way that finishing the
instrumentation handle is deferred.
2024-02-07 14:12:07 +11:00
KJ Tsanaktsidis
8337a9ba55
Ensure that LogSubscriber.flush_all! is called after LogSubscribers run
The Rails::Rack::Logger middleware defers finishing the
request.action_dispatch notification until the body is written. However,
it calls ActiveSupport::LogSubscriber.flush_all! immediately once the
headers are written, before the body is closed.

This means that if you have a custom ActiveSupport::LogSubscriber
attached to request.action_dispatch, any logs you write there are NOT
flushed until the _next_ request finishes (or something else calls
Rails.logger.flush or some such).
2024-01-04 15:58:06 +11:00
Rafael Mendonça França
f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
bogdanvlviv
fd1c8c16c7
Fix test added in #32444
Currently test `#test_logger_does_not_mutate_app_return` doesn't
test mutation of response and the test passes with and without changes
added in #32444. `#freeze` response in the test in order to
test mutation.
2018-04-06 14:00:13 +03:00
Rafael Mendonça França
826b17cd8a
Merge pull request #32444 from matrinox/fix-return-response-mutation-rack-logger
Stop mutating body response
2018-04-04 18:17:16 -04:00
Geoff Lee
0ac64470ea
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>
2018-04-03 19:54:27 -07:00
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Akira Matsuda
9360b6be63 class Foo < Struct.new(:x) creates an extra unneeded anonymous class
because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
2017-01-13 15:13:47 +09:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
Guo Xiang Tan
d9396a07eb Fix incorrect unsubscription. 2014-07-11 16:38:26 +08:00
thedarkone
a0907bbdad "Naked" rescue clauses only catch StandardError subclasses.
Similar to #11497.
2013-08-06 17:04:02 +02:00
thedarkone
3af8a91c38 Add a missing require.
This makes the rack_logger_test.rb runnable by itself (outside of the `rake test` suite).
2013-08-06 17:03:55 +02:00
Rafael Mendonça França
d86ccec097 Use the right instrumentation name
The pattern is event.component

Closes #11769

Conflicts:
	railties/CHANGELOG.md
2013-08-05 18:20:22 -03:00
Aaron Patterson
ffa9540fd3 fire a notification when the request stops / starts 2013-01-09 15:34:58 -08:00