From 9420b90a4eeea50d1faad5c7d51b2060ef1676f9 Mon Sep 17 00:00:00 2001 From: owenpearson Date: Fri, 27 Nov 2026 13:49:20 +0000 Subject: [PATCH] UTS: wait for client B's presence sync before the RTP8 lifecycle enters The sandbox answers the first attach to a new channel with HAS_PRESENCE, even when the channel is empty, and sends the SYNC shortly after. If client A's enter reaches the server before that SYNC goes out, client B receives the member inside the SYNC as PRESENT ahead of the live ENTER, so the RTP8 lifecycle test's first event is not an ENTER. Wait for client B's sync with presence.get() (RTP11c1) before client A attaches, and reword the bulk-enter test's comment to name the first sync, as well as a dropped connection, as a source of PRESENT events. Closes #564 Co-Authored-By: Claude Opus 5.5 --- .../integration/presence_lifecycle_test.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/uts/realtime/integration/presence_lifecycle_test.md b/uts/realtime/integration/presence_lifecycle_test.md index 3fc6a1356..ac182668e 100644 --- a/uts/realtime/integration/presence_lifecycle_test.md +++ b/uts/realtime/integration/presence_lifecycle_test.md @@ -89,9 +89,13 @@ channel_b = client_b.channels.get(channel_name) AWAIT channel_b.attach() # Subscribe on client B before client A enters. Members are counted by clientId from -# both ENTER and PRESENT events: if client B's connection drops mid-test, members it -# missed arrive via the presence re-sync as PRESENT events rather than ENTER, and an -# ENTER-only count would undercount forever. +# both ENTER and PRESENT events, because a member can reach client B as PRESENT rather +# than ENTER. Client B's ATTACHED may carry HAS_PRESENCE even though the channel is +# empty, with a SYNC following it (RTP1): members whose enters reach the server before +# that SYNC goes out arrive inside it as PRESENT, and their ENTERs need not be emitted +# afterwards. Likewise, if client B's connection drops mid-test, members it missed +# arrive via the presence re-sync as PRESENT. An ENTER-only count would undercount +# forever. entered_client_ids = SET() channel_b.presence.subscribe(action: [ENTER, PRESENT], (event) => { entered_client_ids.add(event.clientId) @@ -184,6 +188,12 @@ channel_b.presence.subscribe((event) => { all_events.append(event) }) +# Client B's ATTACHED may carry HAS_PRESENCE even though the channel is empty, with a +# SYNC following it (RTP1). Wait for that SYNC to complete (RTP11c1) before client A +# attaches, so that client A's enter reaches client B live as an ENTER rather than +# inside the SYNC as a PRESENT. +AWAIT channel_b.presence.get() + AWAIT channel_a.attach() # --- Phase 1: Enter ---