Set sensible default timeout if not provided

This commit is contained in:
Kegan Dougal 2022-03-23 12:24:48 +00:00
parent 61bd94fe4b
commit d1e253da21
3 changed files with 3 additions and 4 deletions

View File

@ -64,8 +64,7 @@ export class SlidingSyncConnection {
this.abortController = new AbortController();
const jsonBody = JSON.stringify(reqBody);
let resp = await fetch(
"/_matrix/client/v3/sync?timeout=20000" +
(pos ? "&pos=" + pos : ""),
"/_matrix/client/v3/sync" + (pos ? "?pos=" + pos : ""),
{
signal: this.abortController.signal,
method: "POST",

View File

@ -130,7 +130,7 @@ func (h *SyncLiveHandler) serve(w http.ResponseWriter, req *http.Request) error
var timeout int
if req.URL.Query().Get("timeout") == "" {
timeout = sync3.DefaultTimeoutSecs
timeout = sync3.DefaultTimeoutMSecs
} else {
timeout64, herr := parseIntFromQuery(req.URL, "timeout")
if herr != nil {

View File

@ -17,7 +17,7 @@ var (
SortBy = []string{SortByHighlightCount, SortByName, SortByNotificationCount, SortByRecency}
DefaultTimelineLimit = int64(20)
DefaultTimeoutSecs = 10
DefaultTimeoutMSecs = 10 * 1000 // 10s
)
type Request struct {