RoomMemberEvent.Membership listener on Room never fires (dead handler) #61

Closed
opened 2026-09-12 01:51:20 -04:00 by jared · 0 comments
Owner

Severity: low · Type: bug · Confidence: high

Location: src/app/hooks/useRoomReadPositions.ts:57,61

Problem

RoomMemberEvent.Membership is emitted on the RoomMember object and re-emitted only on the MatrixClient (matrix-js-sdk/lib/sync.js:1758), never on Room. The (room as any).on(RoomMemberEvent.Membership, onMembership) cast silences the type error but the handler can never run, so read-receipt positions are not recomputed when someone joins/leaves — they only refresh on the next receipt. The as any cast is what hid the mistake.

How to trigger

Have a member leave a room while its timeline is open; their read avatar stays until an unrelated receipt arrives.

Suggested fix

Subscribe on the client (mx.on(RoomMemberEvent.Membership, …) filtered by roomId) and drop the as any.


Filed from the September 2026 client audit (branch lotus @ 4bea4895).

**Severity:** low · **Type:** bug · **Confidence:** high **Location:** `src/app/hooks/useRoomReadPositions.ts:57,61` ### Problem `RoomMemberEvent.Membership` is emitted on the `RoomMember` object and re-emitted only on the **MatrixClient** (`matrix-js-sdk/lib/sync.js:1758`), never on `Room`. The `(room as any).on(RoomMemberEvent.Membership, onMembership)` cast silences the type error but the handler can never run, so read-receipt positions are not recomputed when someone joins/leaves — they only refresh on the next receipt. The `as any` cast is what hid the mistake. ### How to trigger Have a member leave a room while its timeline is open; their read avatar stays until an unrelated receipt arrives. ### Suggested fix Subscribe on the client (`mx.on(RoomMemberEvent.Membership, …)` filtered by `roomId`) and drop the `as any`. --- _Filed from the September 2026 client audit (branch `lotus` @ 4bea4895)._
jared added this to the Audit 2026-09 · Medium & Low milestone 2026-09-12 01:51:20 -04:00
jared added the bugpriority: lowarea: messaging labels 2026-09-12 01:51:20 -04:00
jared self-assigned this 2026-09-12 01:51:20 -04:00
jared closed this issue 2026-09-12 20:29:01 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#61