From c0badabade9d9644466655708b06bd4792f74d4c Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Mon, 23 Feb 2026 16:22:09 -0800 Subject: [PATCH] fix: reduce timeout for manifest download Signed-off-by: Harper, Jason M --- cmd/root.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 772bef7f..e572c558 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -240,7 +240,7 @@ func initializeApplication(cmd *cobra.Command, args []string) error { slog.Debug("Checking for perfspect updates") updateAvailable, latestManifest, err := checkForUpdates(gVersion) if err != nil { - slog.Error(err.Error()) + slog.Error(fmt.Sprintf("Error while checking for updates: %v", err)) } else if updateAvailable { fmt.Fprintf(os.Stderr, "A new version (%s) of %s is available!\nPlease run '%s update' to update to the latest version.\n\n", latestManifest.Version, app.Name, app.Name) } else { @@ -471,11 +471,17 @@ type manifest struct { func getLatestManifest() (manifest, error) { // download manifest file from server url := artifactoryUrl + "manifest.json" - resp, err := http.Get(url) + client := &http.Client{ + Timeout: 2 * time.Second, // want to timeout relatively quickly if we can't reach the server + } + resp, err := client.Get(url) if err != nil { return manifest{}, err } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return manifest{}, fmt.Errorf("failed to fetch manifest, status: %s", resp.Status) + } buf := new(bytes.Buffer) _, err = io.Copy(buf, resp.Body) if err != nil {