Skip to content

Commit

Permalink
handle response nil, close response.Body
Browse files Browse the repository at this point in the history
  • Loading branch information
brianolson committed Nov 22, 2024
1 parent b6f34c7 commit 6a25c33
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bgs/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6a25c33

Please sign in to comment.