Skip to content

Commit

Permalink
Increase timeout of init sync to 30mn for small homeservers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Velten committed Jun 27, 2023
1 parent 57c25ab commit 3bf3f23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion sync2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"time"

"github.com/matrix-org/gomatrixserverlib"
"github.com/tidwall/gjson"
Expand Down Expand Up @@ -69,7 +70,15 @@ func (v *HTTPClient) DoSyncV2(ctx context.Context, accessToken, since string, is
if err != nil {
return nil, 0, fmt.Errorf("DoSyncV2: NewRequest failed: %w", err)
}
res, err := v.Client.Do(req)
var res *http.Response
if isFirst {
longTimeoutClient := &http.Client{
Timeout: 30 * time.Minute,
}
res, err = longTimeoutClient.Do(req)
} else {
res, err = v.Client.Do(req)
}
if err != nil {
return nil, 0, fmt.Errorf("DoSyncV2: request failed: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Setup(destHomeserver, postgresURI, secret string, opts Opts) (*handler2.Han
// Setup shared DB and HTTP client
v2Client := &sync2.HTTPClient{
Client: &http.Client{
Timeout: 5 * time.Minute,
Timeout: 45 * time.Second,
},
DestinationServer: destHomeserver,
}
Expand Down

0 comments on commit 3bf3f23

Please sign in to comment.