Skip to content

Remove duplicate X-Request-Id response header

Stan Hu requested to merge sh-fix-performance-bar-ajax-requests into master

This fixes the performance bar not working with AJAX requests.

Both LabKit and Rails were injecting duplicate X-Request-Id headers into the response stream, which caused the frontend to be interpret the value as a comma-separated value (e.g. LdEgVXsp1R4, LdEgVXsp1R4).

The new flow behaves as the following:

  1. Workhorse injects X-Request-Id to the inbound HTTP request to Rails
  2. Rails looks up this value in its RequestId middleware. Since the value exists, Rails sets the X-Request-Id response header to this value: https://github.com/rails/rails/blob/c4d3e202e10ae627b3b9c34498afb45450652421/actionpack/lib/action_dispatch/middleware/request_id.rb#L29-L30
  3. Workhorse doesn't append another header in the response.

Distributed tracing still works fine with any request that gets sent to Rails, but for any endpoints that bypass Rails should still work fine because Workhorse still generates the initial correlation ID.

Note: Once labkit!17 (diffs) is merged, we can restore the response header.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/60111

Edited by Stan Hu

Merge request reports