Skip to content

Commit

Permalink
fix: treat timeouts < 0 as no timeout
Browse files Browse the repository at this point in the history
Otherwise we'd end up setting a deadline in the past which would cause
the request to immediately time out before it even started, which makes
no sense.
  • Loading branch information
felixge committed Mar 25, 2021
1 parent 8d4e562 commit b3cf200
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion profiler/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func (p *profiler) doRequest(bat batch) error {
return err
}
ctx := context.Background()
if p.cfg.uploadTimeout != 0 {
// uploadTimeout should always be > 0 (see DefaultUploadTimeout) unless the
// user explicitly sets it to 0 or a negative number to disable the timeout.
if p.cfg.uploadTimeout > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(context.Background(), p.cfg.uploadTimeout)
defer cancel()
Expand Down

0 comments on commit b3cf200

Please sign in to comment.