summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorNick Mills-Barrett <nick@beeper.com>2022-07-26 18:45:27 +0100
committerGitHub <noreply@github.com>2022-07-26 17:45:27 +0000
commitbf3115584c876392e7849cd4ba2271165572588d (patch)
treec3539541f55a89a29a43d44cd1ea310c3646ce2e /synapse
parentExtend the release script to automatically push a new SyTest branch, rather t... (diff)
downloadsynapse-bf3115584c876392e7849cd4ba2271165572588d.tar.xz
Copy room serials before handling in `get_new_events_as` (#13392)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/typing.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index d104ea07fe..27aa0d3126 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -489,8 +489,15 @@ class TypingNotificationEventSource(EventSource[int, JsonDict]):
             handler = self.get_typing_handler()
 
             events = []
-            for room_id in handler._room_serials.keys():
-                if handler._room_serials[room_id] <= from_key:
+
+            # Work on a copy of things here as these may change in the handler while
+            # waiting for the AS `is_interested_in_room` call to complete.
+            # Shallow copy is safe as no nested data is present.
+            latest_room_serial = handler._latest_room_serial
+            room_serials = handler._room_serials.copy()
+
+            for room_id, serial in room_serials.items():
+                if serial <= from_key:
                     continue
 
                 if not await service.is_interested_in_room(room_id, self._main_store):
@@ -498,7 +505,7 @@ class TypingNotificationEventSource(EventSource[int, JsonDict]):
 
                 events.append(self._make_event_for(room_id))
 
-            return events, handler._latest_room_serial
+            return events, latest_room_serial
 
     async def get_new_events(
         self,