Skip to content

Commit 2c5b038

Browse files
authored
Set HTTP client timeout to 30 seconds (#153)
* Set HTTP client timeout to 30 seconds * Add an explanation for why we set http.Server's Timeout
1 parent 5da967b commit 2c5b038

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/client/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net/http"
2121
"net/url"
2222
"nhooyr.io/websocket"
23+
"time"
2324
)
2425

2526
var (
@@ -77,6 +78,11 @@ func New(opts ...Option) (*Client, error) {
7778

7879
// Instantiate the HTTP client
7980
client.httpClient = &http.Client{
81+
// The default is zero, which means no timeout, which means that
82+
// the requests may hang indefinitely. See [1] for more details.
83+
//
84+
// [1]: https://github.com/cirruslabs/orchard/issues/152#issuecomment-1927091747
85+
Timeout: 30 * time.Second,
8086
Transport: &http.Transport{
8187
TLSClientConfig: client.tlsConfig,
8288
},

0 commit comments

Comments
 (0)