Spec requirement
RTP18a: "If a new SYNC is initiated while a previous SYNC sequence is in progress, the previous sync should be discarded and the new one should replace it." The residual members set should be reset to the current map contents when a new sync starts mid-flight.
Current behavior
startSync() in presencemap.ts (line ~131-145) has an explicit guard:
if (!this.syncInProgress) {
this.residualMembers = Utils.copy(map);
this.setInProgress(true);
}
When called during an in-progress sync, syncInProgress is already true, so residualMembers is NOT reset. This means members from the first sync's residualMembers set persist, and when the second sync completes, endSync() may incorrectly evict members that were present in the second sync sequence but not explicitly seen (because they were already removed from residualMembers during the first sync's processing).
Root cause
The if (!this.syncInProgress) guard in startSync() was likely intended to be idempotent for duplicate START messages, but it also prevents reset when a genuinely new sync sequence begins. The fix would be to always reset residualMembers = Utils.copy(map) regardless of syncInProgress.
UTS test
RTP18a - new sync discards previous in-flight sync in test/uts/realtime/unit/presence/presence_sync.test.ts
Found via UTS (Universal Test Specification) compliance testing.
┆Issue is synchronized with this Jira Task by Unito
Spec requirement
RTP18a: "If a new SYNC is initiated while a previous SYNC sequence is in progress, the previous sync should be discarded and the new one should replace it." The residual members set should be reset to the current map contents when a new sync starts mid-flight.
Current behavior
startSync()inpresencemap.ts(line ~131-145) has an explicit guard:When called during an in-progress sync,
syncInProgressis already true, soresidualMembersis NOT reset. This means members from the first sync'sresidualMembersset persist, and when the second sync completes,endSync()may incorrectly evict members that were present in the second sync sequence but not explicitly seen (because they were already removed fromresidualMembersduring the first sync's processing).Root cause
The
if (!this.syncInProgress)guard instartSync()was likely intended to be idempotent for duplicate START messages, but it also prevents reset when a genuinely new sync sequence begins. The fix would be to always resetresidualMembers = Utils.copy(map)regardless ofsyncInProgress.UTS test
RTP18a - new sync discards previous in-flight syncintest/uts/realtime/unit/presence/presence_sync.test.tsFound via UTS (Universal Test Specification) compliance testing.
┆Issue is synchronized with this Jira Task by Unito