Skip to content

Commit

Permalink
fix: goroutine leak for flightrecorder send data
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
  • Loading branch information
szuecs committed Jul 1, 2024
1 parent 502871b commit 0498acc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions proxy/flightrecorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func TestFlightRecorder(t *testing.T) {
if err != nil {
t.Fatalf("Failed to GET %q: %v", pr.URL, err)
}
defer rsp.Body.Close()
_, err = io.ReadAll(rsp.Body)
if err != nil {
t.Fatalf("Failed to read body: %v", err)
}

switch rsp.StatusCode {
case 200, 201, 204:
Expand Down
4 changes: 3 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,11 @@ func (p *Proxy) writeTraceIfTooSlow(ctx *context) {
p.log.Errorf("Failed to create request to %q to send a trace: %v", p.flightRecorderURL.String(), err)
}

rsp, err := http.DefaultClient.Do(req)
rsp, err := p.roundTripper.RoundTrip(req)
if err != nil {
p.log.Errorf("Failed to write trace to %q: %v", p.flightRecorderURL.String(), err)
} else {
rsp.Body.Close()
}
switch rsp.StatusCode {
case 200, 201, 204:
Expand Down

0 comments on commit 0498acc

Please sign in to comment.