Skip to content

Commit 22225a4

Browse files
authored
fix: deadlock waiting for targets if report marshal fails (#400)
1 parent 7ae33e8 commit 22225a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/proxy/http.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ func (h *HttpProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
196196
body, err := io.ReadAll(response.Body)
197197
if err != nil {
198198
h.log.Error(err, "failed to read response body", "request", r.RequestURI)
199-
continue
200199
}
201200

201+
defer func() {
202+
_ = response.Body.Close()
203+
}()
204+
202205
reportResponse.Targets = append(reportResponse.Targets, ReportTargetResponse{
203206
StatusCode: response.StatusCode,
204207
Body: string(body),
@@ -234,7 +237,6 @@ func (h *HttpProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
234237
_, err = w.Write(body)
235238
if err != nil {
236239
h.log.Error(err, "failed to write body", "request", r.RequestURI)
237-
return
238240
}
239241

240242
return

0 commit comments

Comments
 (0)