Skip to content

Commit 1c51106

Browse files
Bump the Postman client timeout (#4183)
Sometimes when we're getting really large collections, these requests can take a long time. Bumping timeouts isn't likely the best solution long term, but it should help now. Also moved where we define the http client into the postman client itself and cleaned up some import ordering
1 parent 867fa01 commit 1c51106

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/sources/postman/postman.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"google.golang.org/protobuf/types/known/anypb"
1919

2020
"github.com/go-errors/errors"
21-
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
2221
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"
2322
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
2423
"github.com/trufflesecurity/trufflehog/v3/pkg/sources"
@@ -121,7 +120,6 @@ func (s *Source) Init(ctx context.Context, name string, jobId sources.JobID, sou
121120
return errors.New("Postman token is empty")
122121
}
123122
s.client = NewClient(conn.GetToken(), s.metrics)
124-
s.client.HTTPClient = common.RetryableHTTPClientTimeout(10)
125123
log.RedactGlobally(conn.GetToken())
126124
case *sourcespb.Postman_Unauthenticated:
127125
s.client = nil

pkg/sources/postman/postman_client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"strconv"
99
"time"
1010

11-
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
1211
"golang.org/x/time/rate"
1312

13+
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
14+
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
1415
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"
1516
)
1617

@@ -214,7 +215,10 @@ func NewClient(postmanToken string, metrics *metrics) *Client {
214215
}
215216

216217
c := &Client{
217-
HTTPClient: http.DefaultClient,
218+
// Requests for large objects (usually collections) take a long time. While we don't think that _every_
219+
// request will take this long, some might take 5 seconds or more. This seems reasonable, but we should
220+
// be very cautious about bumping it further
221+
HTTPClient: common.RetryableHTTPClientTimeout(30),
218222
Headers: bh,
219223
WorkspaceAndCollectionRateLimiter: rate.NewLimiter(rate.Every(time.Second), 1),
220224
GeneralRateLimiter: rate.NewLimiter(rate.Every(time.Second/5), 1),

0 commit comments

Comments
 (0)