Skip to content

Commit

Permalink
Return CurrentPosition if the request timed out
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed May 11, 2022
1 parent 4081d11 commit 7dbdda9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions syncapi/sync/requestpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
giveup := func() util.JSONResponse {
syncReq.Log.Debugln("Responding to sync since client gave up or timeout was reached")
syncReq.Response.NextBatch = syncReq.Since

// The request timed out and wasn't woken up by the streams, advance NextBatch to avoid hitting
// /sync and returning immediately
if !timer.Stop() {
syncReq.Log.Traceln("Advancing next batch, as request wasn't woken by streams")
syncReq.Response.NextBatch = rp.Notifier.CurrentPosition()
}
// We should always try to include OTKs in sync responses, otherwise clients might upload keys
// even if that's not required. See also:
// https://github.com/matrix-org/synapse/blob/29f06704b8871a44926f7c99e73cf4a978fb8e81/synapse/rest/client/sync.py#L276-L281
Expand Down

0 comments on commit 7dbdda9

Please sign in to comment.