Skip to content

Commit

Permalink
fix: use default retry logic
Browse files Browse the repository at this point in the history
It looks like the default logic does what we need with 429 errors. This fixes a nil pointer issue that happens when resp is nil, but err is set, since this checks the err as well.
  • Loading branch information
aliscott committed Feb 20, 2024
1 parent bcf4fc7 commit e68aad1
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions internal/hcl/modules/registry.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package modules

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -165,17 +164,6 @@ func (d *Disco) DownloadLocation(moduleURL RegistryURL, version string) (string,
func newRetryableClient() *retryablehttp.Client {
httpClient := retryablehttp.NewClient()
httpClient.Logger = &apiclient.LeveledLogger{Logger: logging.Logger.With().Str("library", "retryablehttp").Logger()}
httpClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
if ctx.Err() != nil {
return false, ctx.Err()
}

if resp.StatusCode == http.StatusTooManyRequests {
return true, nil
}

return false, err
}
return httpClient
}

Expand Down

0 comments on commit e68aad1

Please sign in to comment.