File tree Expand file tree Collapse file tree
lib/react_on_rails_pro/concerns Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ def emit_rsc_stream_server_timing_header
171171 desc = "RoR Pro streamed RSC shell render (includes first renderer chunk)"
172172 entry = "ror_stream_shell;dur=#{ duration } ;desc=\" #{ desc } \" "
173173 existing = response . headers [ "Server-Timing" ]
174- response . headers [ "Server-Timing" ] = existing . present? ? "#{ existing } , #{ entry } " : entry
174+ entries = Array ( existing ) . flatten . compact . reject ( &:blank? ) + [ entry ]
175+ response . headers [ "Server-Timing" ] = entries . join ( ", " )
175176 rescue StandardError => e
176177 # Observability must never break a real response. Swallow and log.
177178 begin
Original file line number Diff line number Diff line change @@ -225,6 +225,20 @@ def build_mocked_response
225225 expect ( server_timing ) . to start_with ( "action_total;dur=5, ror_stream_shell;dur=" )
226226 end
227227
228+ it "appends to array-valued Server-Timing headers without stringifying the array" do
229+ _queues , controller , stream = setup_stream_test ( component_count : 0 )
230+ allow ( stream ) . to receive ( :write )
231+ controller . response . headers [ "Server-Timing" ] = [ "cdn-cache;dur=10" ]
232+
233+ run_stream ( controller , rsc_stream_observability : true ) do |_parent |
234+ sleep 0.1
235+ end
236+
237+ server_timing = controller . response . headers [ "Server-Timing" ]
238+ expect ( server_timing ) . to start_with ( "cdn-cache;dur=10, ror_stream_shell;dur=" )
239+ expect ( server_timing ) . not_to include ( "[" )
240+ end
241+
228242 it "swallows Server-Timing header emission errors even when logging fails" do
229243 _queues , controller , _stream = setup_stream_test ( component_count : 0 )
230244 failing_headers = instance_double ( Hash )
You can’t perform that action at this time.
0 commit comments