Skip to content

Commit 7857839

Browse files
committed
Fix ENHANCE_YOUR_CALM too_many_pings error for the proxy agent following https://blog.cloudflare.com/go-and-enhance-your-calm/
1 parent 05d659d commit 7857839

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

agent/utils/utils.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ func ListPendingRequests(ctx context.Context, client *http.Client, proxyHost, ba
241241
if err != nil {
242242
return nil, fmt.Errorf("A proxy request failed: %q", err.Error())
243243
}
244-
defer proxyResp.Body.Close()
244+
defer func() {
245+
io.Copy(io.Discard, proxyResp.Body)
246+
proxyResp.Body.Close()
247+
}()
245248
return parseRequestIDs(proxyResp, metricHandler)
246249
}
247250

@@ -371,6 +374,7 @@ func postResponseWithRetries(client *http.Client, proxyURL, backendID, requestID
371374
}
372375
continue
373376
}
377+
io.Copy(io.Discard, proxyResp.Body)
374378
proxyResp.Body.Close()
375379
if 500 <= proxyResp.StatusCode && proxyResp.StatusCode < 600 {
376380
if _, seekErr := proxyReadSeeker.Seek(0, io.SeekStart); seekErr != nil {

0 commit comments

Comments
 (0)