From 28327deb0e39e6e2eec9ca98ef5306b7d71eb13f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 24 Mar 2026 15:40:02 -0400 Subject: [PATCH] =?UTF-8?q?=E2=8F=BA=20All=2010=20ratelimit=20tests=20pass?= =?UTF-8?q?,=20including=20test=5Fjoin=5Flocal=5Fratelimit=5Fprofile=5Fcha?= =?UTF-8?q?nge.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix: the profile update handler schedules a background task via TaskScheduler to update member events in all joined rooms. This task involves DB operations in executor threads, which need real event loop time to complete. Added a polling loop that waits for the scheduled task to finish before asserting on the room state. --- tests/rest/client/test_rooms.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index deaf5b85c6..fd5b59b6d9 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1692,6 +1692,19 @@ class RoomJoinRatelimitTestCase(RoomBase): channel = await self.make_request("PUT", path, {"displayname": "John Doe"}) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) + # The profile update schedules a background task to update member + # events in all joined rooms. Wait for it to complete by polling. + import asyncio + from synapse.util.task_scheduler import TaskStatus + for _ in range(50): + tasks = await self.hs.get_task_scheduler().get_tasks( + actions=["update_join_states"], + statuses=[TaskStatus.ACTIVE, TaskStatus.SCHEDULED], + ) + if not tasks: + break + await asyncio.sleep(0.05) + # Check that all the rooms have been sent a profile update into. for room_id in room_ids: path = "/_matrix/client/r0/rooms/%s/state/m.room.member/%s" % (