git » sdk » commit e350363

Add trace for when we skip sync

author Eric Roberts
2026-10-02 17:19:57 UTC
committer Stephen Paul Weber
2026-10-05 14:21:10 UTC
parent 6bcd88d92463fde8b0e987dc28cd855e69485f13

Add trace for when we skip sync

I'm seeing channels get stuck in sync, and I can see that the join
process was started, but I don't see that a sync was initialized. This
seems like the only place that could be deciding to skip that, and I
don't see any error logs that would indicate a different problem.

I've seen multiple joins happen over a span of hours, so if they're all
being skipped because of an existing sync, I want to know what time we
started that.

I suspect that there can't actually be an active sync going on, but
maybe something stalled out? I don't know. Hopefully this helps. I only
get this happening when I open my laptop in the morning, so tomorrow
morning I guess I'll see what happens.

borogove/Chat.hx +16 -2
borogove/MessageSync.hx +2 -0

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index 68a98a1..96f78ef 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -1525,7 +1525,7 @@ class Channel extends Chat {
 	private var inSync = false;
 	@:allow(borogove)
 	private var joinFailed = null;
-	private var sync = null;
+	private var sync: Null<MessageSync> = null;
 	private var forceLive = false;
 	@:allow(borogove)
 	private var self: Null<Member> = null;
@@ -1896,7 +1896,21 @@ class Channel extends Chat {
 			);
 			return;
 		}
-		if (sync != null) return;
+		if (sync != null) {
+			trace(
+				"SYNC: channel doSync skipped, sync already exists",
+				{
+					chatId: chatId,
+					inSync: inSync,
+					startedAt: Date.format(std.Date.fromTime(sync.startedAt)),
+					elapsedMs: std.Date.now().getTime() - sync.startedAt,
+					progress: sync.progress,
+					lastPage: sync.lastPage,
+					hasMore: sync.hasMore(),
+				}
+			);
+			return;
+		}
 
 		// Sort into a window so live messages arriving concurrently can come after
 		final sortFrom = sortA ?? syncPoint?.sortId;
diff --git a/borogove/MessageSync.hx b/borogove/MessageSync.hx
index fbf6cc5..eac1bc7 100644
--- a/borogove/MessageSync.hx
+++ b/borogove/MessageSync.hx
@@ -35,12 +35,14 @@ class MessageSync {
 	private final startFilter:MessageFilter;
 	private var sortA:Null<String>;
 	private final sortB:Null<String>;
+	public final startedAt:Float;
 	public var lastPage(default, null):ResultSetPageResult;
 	public var progress(default, null): Int = 0;
 	private var complete:Bool = false;
 	public var jmi(default, null): Map<String, Stanza> = [];
 
 	public function new(client:Client, stream:GenericStream, filter:MessageFilter, sortA: Null<String>, sortB: Null<String>, ?serviceJID:String) {
+		this.startedAt = std.Date.now().getTime();
 		this.client = client;
 		this.stream = stream;
 		this.startFilter = this.filter = Reflect.copy(filter);