Skip to content

Send PRESENCE_SUBSCRIBE before the presence update that follows it - #1965

Closed
joepio wants to merge 1 commit into
developfrom
claude/presence-subscribe-order-9v8w8o
Closed

joepio wants to merge 1 commit into
developfrom
claude/presence-subscribe-order-9v8w8o

Conversation

@joepio

@joepio joepio commented Oct 1, 2026

Copy link
Copy Markdown
Member

Requested by Joep · project thread

Before: the first presence update on a connection (and the rebroadcast after authentication or reconnect) went out ahead of PRESENCE_SUBSCRIBE, so the server logged presence update from non-subscriber and dropped it. Only the 10 second heartbeat recovered it.

After: the update is held until the subscribe frame is on the wire and sent right behind it.

subscribePresence() defers its frame behind authenticate().then(...) (a microtask at best), while DrivePresenceManager and reSubscribeAll() send synchronously. WSClient now keeps a short per-drive hold (max 16 updates) while a subscribe is pending. Nothing is held before authentication (the existing "no presence before auth" rule is unchanged), and unsubscribePresence, an identity change or a failed handshake drop what was held. The server's subscribe-time read check stays the only gate; no server change.

How: three frame-level tests in websockets.test.ts. The first two fail on develop (update precedes subscribe) and pass now; the third covers withdrawal. Full lib suite (1090 tests), tsc -b, oxlint and oxfmt pass. Not run here: pnpm run -r lint and the browser two-tab test (the full workspace install is blocked in this container), so a Mancave run is still needed.


Generated by Claude Code

subscribePresence() is deferred behind authenticate().then(), while the
presence manager sends its first update (and reSubscribeAll() its
rebroadcast) synchronously. The update reached the server ahead of the
subscribe frame and was dropped as 'presence update from non-subscriber'.

Hold presence updates for a drive while its subscribe is pending and send
them right behind it. Nothing is held before authentication, and a
withdrawn subscription drops what was held, so the server's subscribe-time
read check stays the only gate.
@joepio

joepio commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

Trekmeester: included in batch #1966 (run 36898843808). It lands when that run is green; if this PR breaks something there, I take it out and say why here.

@joepio

joepio commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

Landed through batch #1966 (squash 5e189e6, green run 36970563089). Fixes made while batching are listed in #1966.

@joepio joepio closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant