Skip to content

Commit f86b847

Browse files
authored
refactor(hermes): add http client timeout to fetch the binary (#252)
1 parent c5ac031 commit f86b847

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hermes/pkg/hermes/bin.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"path/filepath"
1212
"runtime"
1313
"strings"
14+
"time"
1415

1516
"github.com/ignite/cli/v29/ignite/config"
1617
"github.com/ignite/cli/v29/ignite/pkg/errors"
@@ -38,6 +39,10 @@ var archMap = map[string]string{
3839
"386": "i386",
3940
}
4041

42+
var httpClient = &http.Client{
43+
Timeout: 30 * time.Second,
44+
}
45+
4146
var osMap = map[string]string{
4247
"darwin": "apple-darwin",
4348
"linux": "unknown-linux-gnu",
@@ -112,7 +117,7 @@ func getHermesAssetURL(version string) (string, error) {
112117
expectedAssetName := fmt.Sprintf("hermes-%s-%s-%s.tar.gz", version, archMapped, osMapped)
113118

114119
// Request release metadata from GitHub
115-
resp, err := http.Get(apiURL + version)
120+
resp, err := httpClient.Get(apiURL + version)
116121
if err != nil {
117122
return "", errors.Errorf("failed to fetch release info: %w", err)
118123
}
@@ -152,7 +157,7 @@ func downloadAndExtractHermes(downloadURL, version string) (string, error) {
152157
}
153158
defer out.Close()
154159

155-
resp, err := http.Get(downloadURL)
160+
resp, err := httpClient.Get(downloadURL)
156161
if err != nil {
157162
return "", errors.Errorf("failed to download binary: %w", err)
158163
}

0 commit comments

Comments
 (0)