From 2b6098eae9d4db7056123bc801fc50c79c4eff41 Mon Sep 17 00:00:00 2001 From: Bunlong Heng Date: Sat, 8 Aug 2026 10:44:10 -0400 Subject: [PATCH] fix(search-jobs): add timeout to authenticated HTTP requests --- cmd/src/search_jobs_logs.go | 4 +++- cmd/src/search_jobs_results.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/src/search_jobs_logs.go b/cmd/src/search_jobs_logs.go index 6327a609ab..a14b2b64c5 100644 --- a/cmd/src/search_jobs_logs.go +++ b/cmd/src/search_jobs_logs.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "time" "github.com/sourcegraph/src-cli/internal/api" "github.com/sourcegraph/src-cli/internal/cmderrors" @@ -24,7 +25,8 @@ func fetchJobLogs(jobID string, logURL string) (io.ReadCloser, error) { req.Header.Add("Authorization", "token "+cfg.accessToken) - resp, err := http.DefaultClient.Do(req) + client := &http.Client{Timeout: 60 * time.Second} + resp, err := client.Do(req) if err != nil { return nil, err } diff --git a/cmd/src/search_jobs_results.go b/cmd/src/search_jobs_results.go index 9d8bc7a9ab..95d708ed13 100644 --- a/cmd/src/search_jobs_results.go +++ b/cmd/src/search_jobs_results.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "time" "github.com/sourcegraph/src-cli/internal/api" "github.com/sourcegraph/src-cli/internal/cmderrors" @@ -24,7 +25,8 @@ func fetchJobResults(jobID string, resultsURL string) (io.ReadCloser, error) { req.Header.Add("Authorization", "token "+cfg.accessToken) - resp, err := http.DefaultClient.Do(req) + client := &http.Client{Timeout: 60 * time.Second} + resp, err := client.Do(req) if err != nil { return nil, err }