Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit bf31155

Browse files
authored
Copy room serials before handling in get_new_events_as (#13392)
1 parent 543dc9c commit bf31155

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

changelog.d/13392.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in handling of typing events for appservices. Contributed by Nick @ Beeper (@fizzadar).

synapse/handlers/typing.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,16 +489,23 @@ async def get_new_events_as(
489489
handler = self.get_typing_handler()
490490

491491
events = []
492-
for room_id in handler._room_serials.keys():
493-
if handler._room_serials[room_id] <= from_key:
492+
493+
# Work on a copy of things here as these may change in the handler while
494+
# waiting for the AS `is_interested_in_room` call to complete.
495+
# Shallow copy is safe as no nested data is present.
496+
latest_room_serial = handler._latest_room_serial
497+
room_serials = handler._room_serials.copy()
498+
499+
for room_id, serial in room_serials.items():
500+
if serial <= from_key:
494501
continue
495502

496503
if not await service.is_interested_in_room(room_id, self._main_store):
497504
continue
498505

499506
events.append(self._make_event_for(room_id))
500507

501-
return events, handler._latest_room_serial
508+
return events, latest_room_serial
502509

503510
async def get_new_events(
504511
self,

0 commit comments

Comments
 (0)