From 4e0249cd2f83a778804781f3f811e2eb6aea9ee1 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 15 Oct 2025 21:59:01 +0000 Subject: [PATCH] Fix sliding-sync again by resetting after interrupted requests. (fixes #190) This solution is not elegant but appears to be correct for fixing the issue. A a more efficient solution might be possible without resetting the connection which should be further investigated. Signed-off-by: Jason Volk --- src/api/client/sync/v5.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/client/sync/v5.rs b/src/api/client/sync/v5.rs index 32b5e785..af02c022 100644 --- a/src/api/client/sync/v5.rs +++ b/src/api/client/sync/v5.rs @@ -23,7 +23,7 @@ use ruma::{ }; use tokio::time::{Instant, timeout_at}; use tuwunel_core::{ - Result, apply, at, + Err, Result, apply, at, debug::INFO_SPAN_LEVEL, err, error::inspect_log, @@ -119,6 +119,10 @@ pub(crate) async fn sync_events_v5_route( let (mut conn, _) = join(conn, ping_presence).await; + if conn.next_batch != since { + return Err!(Request(UnknownPos("Requesting unknown or duplicate 'pos' parameter."))); + } + conn.update_cache(request); conn.globalsince = since; conn.next_batch = since;