Return CurrentPosition if the request timed out

This commit is contained in:
Till Faelligen 2022-05-11 08:48:52 +02:00
parent 4081d11a17
commit 7dbdda9641

View file

@ -250,6 +250,13 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
giveup := func() util.JSONResponse { giveup := func() util.JSONResponse {
syncReq.Log.Debugln("Responding to sync since client gave up or timeout was reached") syncReq.Log.Debugln("Responding to sync since client gave up or timeout was reached")
syncReq.Response.NextBatch = syncReq.Since 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 // We should always try to include OTKs in sync responses, otherwise clients might upload keys
// even if that's not required. See also: // even if that's not required. See also:
// https://github.com/matrix-org/synapse/blob/29f06704b8871a44926f7c99e73cf4a978fb8e81/synapse/rest/client/sync.py#L276-L281 // https://github.com/matrix-org/synapse/blob/29f06704b8871a44926f7c99e73cf4a978fb8e81/synapse/rest/client/sync.py#L276-L281