Repository navigation
UTS: wait for client B's presence sync before the RTP8 lifecycle enters - #587
Open
owenpearson wants to merge 1 commit into
Open
owenpearson wants to merge 1 commit into
owenpearson wants to merge 1 commit into
Conversation
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 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #564
The race
realtime/integration/RTP8/enter-update-leave-lifecycle-0attaches client B, subscribes, attaches client A and enters, then asserts that client B's first presence event is an ENTER. Nothing waits for client B's initial presence sync.The sandbox answers the first attach to a new channel with
HAS_PRESENCEeven though the channel is empty, and sends aSYNCshortly after. RTP1 allows this ("the sync may be empty"), so the server is not at fault. If client A's enter reaches the server before thatSYNCgoes out, theSYNCcarries the member to client B as PRESENT, ahead of the live ENTER (which carries the same id), and the first assertion fails.Measured against the sandbox:
HAS_PRESENCEin 738 of 738 runs (presence_lifecycle_test.md's RTP8 test races the server's first presence sync, so the first event can be PRESENT rather than ENTER #564) and in 168 of 168 in a re-run for this PR, json and msgpack alike. TheSYNCfollowed a median of 80ms later (90th percentile 96ms).ATTACHED, swept from 50 to 105ms: 28 of 336 runs saw PRESENT first without the wait, every one between 50 and 84ms. With the wait, 0 of 336.HAS_PRESENCEin 82 of 84 runs without the wait, so client A was attaching, and entering, before client B's sync had gone out. With the wait, 0 of 84. (Local latency kept the enter outside the window in those runs, so none saw PRESENT first.)expected 'present' to equal 'enter'atpresence_lifecycle.test.ts:180, in 31 jobs across 28 failed runs of "Test NodeJS (UTS)" since 2026-10-22. ably-python's derived test failed this way six times in CI in a week. ably-dotnet's derived test sees a PRESENT among the events too.The fix
AWAIT channel_b.presence.get()(RTP11c1) between client B's subscribe and client A's attach, so client A's enter reaches client B live.get()returns an empty list there, and every assertion stands.Test IDs are unchanged.
npm run lintpasses.Not addressed here: RTP2a/RTP2b2 don't say whether an incoming message with an equal id counts as newer, which decides whether the duplicate ENTER is discarded or emitted after the PRESENT. The fix makes the first event an ENTER either way.
🤖 Generated with Claude Code