Skip to content

Commit

Permalink
ENG-6200: Turn client timeout into a response header timeout (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickpintor committed Apr 23, 2024
1 parent 7c871b9 commit 155ed97
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,21 @@ func NewClient(secret string, timeouts Timeouts, configFns ...ClientConfigFn) *C
Timeout: timeouts.ConnectionTimeout,
}

// NOTE: prefer a response header timeout instead of a client timeout so
// that the client don't stop reading a http body that was produced by
// Fauna. On the query interface, an HTTP body is sent as a single http
// message. On the streaming interface, HTTP chunks are sent on every event.
// Therefore, it's in the driver's best interest to continue reading the
// HTTP body once the headers appear.
httpClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialer.DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 20,
IdleConnTimeout: timeouts.IdleConnectionTimeout,
Proxy: http.ProxyFromEnvironment,
DialContext: dialer.DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 20,
IdleConnTimeout: timeouts.IdleConnectionTimeout,
ResponseHeaderTimeout: timeouts.QueryTimeout + timeouts.ClientBufferTimeout,
},
Timeout: timeouts.QueryTimeout + timeouts.ClientBufferTimeout,
}

defaultHeaders := map[string]string{
Expand Down

0 comments on commit 155ed97

Please sign in to comment.