From 6a25c339776d8083c78dedbee77b28ba24ecb00d Mon Sep 17 00:00:00 2001 From: Brian Olson Date: Thu, 21 Nov 2024 21:08:50 -0500 Subject: [PATCH] handle response nil, close response.Body --- bgs/handlers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bgs/handlers.go b/bgs/handlers.go index 3472c107..4fe55fb1 100644 --- a/bgs/handlers.go +++ b/bgs/handlers.go @@ -197,7 +197,10 @@ func (s *BGS) handleComAtprotoSyncRequestCrawl(ctx context.Context, body *comatp for _, rpu := range s.nextCrawlers { pu := rpu.JoinPath("/xrpc/com.atproto.sync.requestCrawl") response, err := s.httpClient.Post(pu.String(), "application/json", bytes.NewReader(bodyBlob)) - if err != nil { + if response != nil && response.Body != nil { + response.Body.Close() + } + if err != nil || response == nil { log.Warnw("requestCrawl forward failed", "host", rpu, "err", err) } else if response.StatusCode != http.StatusOK { log.Warnw("requestCrawl forward failed", "host", rpu, "status", response.Status)