synapse/tests
Erik Johnston 0779587f9f
Lift pausing on ratelimited requests to http layer (#18595)
When a request gets ratelimited we (optionally) wait ~500ms before
returning to mitigate clients that like to tightloop on request
failures. However, this is currently implemented by pausing request
processing when we check for ratelimits, which might be deep within
request processing, and e.g. while locks are held. Instead, let's hoist
the pause to the very top of the HTTP handler.

Hopefully, this mitigates the issue where a user sending lots of events
to a single room can see their requests time out due to the combination
of the linearizer and the pausing of the request. Instead, they should
see the requests 429 after ~500ms.

The first commit is a refactor to pass the `Clock` to `AsyncResource`,
the second commit is the behavioural change.
2025-06-25 14:32:55 +00:00
..
api Export RatelimitOverride from ModuleApi (#18513) 2025-06-06 10:48:49 +00:00
app Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
appservice Recover an appservice if a successful ping occurs. (#18521) 2025-06-06 11:59:38 +00:00
config Fix a couple type annotations in the RootConfig/Config (#18409) 2025-05-13 10:22:15 -05:00
crypto Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
events Fix a couple type annotations in the RootConfig/Config (#18409) 2025-05-13 10:22:15 -05:00
federation Enable flake8-logging and flake8-logging-format rules in Ruff and fix related issues throughout the codebase (#18542) 2025-06-13 09:44:18 +02:00
handlers Speed up MAS token introspection (#18357) 2025-06-16 16:41:35 +01:00
http Enable flake8-logging and flake8-logging-format rules in Ruff and fix related issues throughout the codebase (#18542) 2025-06-13 09:44:18 +02:00
logging Unbreak unit tests with Twisted 25.5.0 by add parsePOSTFormSubmission arg to FakeSite (#18577) 2025-06-24 11:52:06 +01:00
media Add media repository callbacks to module API to control media upload size (#18457) 2025-06-04 11:33:10 +01:00
metrics Add a unit test for the phone home stats (#18463) 2025-05-20 16:26:45 +01:00
module_api Add user_may_send_state_event callback to spam checker module API (#18455) 2025-06-04 11:26:04 +00:00
push Do not retry push during backoff period (#18363) 2025-04-29 14:08:11 +01:00
replication Unbreak unit tests with Twisted 25.5.0 by add parsePOSTFormSubmission arg to FakeSite (#18577) 2025-06-24 11:52:06 +01:00
rest Add report user API from MSC4260 (#18120) 2025-06-20 13:02:14 +01:00
scripts Update license headers 2023-11-21 15:29:58 -05:00
server_notices Sliding Sync: Add cache to get_tags_for_room(...) (#17730) 2024-09-19 12:43:26 +01:00
state bugfix: calculate the PL for non-creators correctly in v11 rooms (#18547) 2025-06-13 12:56:39 +01:00
storage Unbreak unit tests with Twisted 25.5.0 by add parsePOSTFormSubmission arg to FakeSite (#18577) 2025-06-24 11:52:06 +01:00
test_utils Bump ruff from 0.7.3 to 0.11.10 (#18451) 2025-05-20 15:23:30 +01:00
types Use immutabledict instead of frozendict (#15113) 2023-03-22 17:15:34 +00:00
util Fix bug where sliding sync ignored room_id_to_include option (#18535) 2025-06-13 11:29:23 +01:00
__init__.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
server.py Unbreak unit tests with Twisted 25.5.0 by add parsePOSTFormSubmission arg to FakeSite (#18577) 2025-06-24 11:52:06 +01:00
test_distributor.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
test_event_auth.py Format files with Ruff (#17643) 2024-09-02 12:39:04 +01:00
test_mau.py Update license headers 2023-11-21 15:29:58 -05:00
test_phone_home.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
test_rust.py Add missing type hints to tests. (#15027) 2023-02-08 19:52:37 +00:00
test_server.py Lift pausing on ratelimited requests to http layer (#18595) 2025-06-25 14:32:55 +00:00
test_state.py Bump ruff from 0.7.3 to 0.11.10 (#18451) 2025-05-20 15:23:30 +01:00
test_terms_auth.py Update license headers 2023-11-21 15:29:58 -05:00
test_test_utils.py Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
test_types.py Format files with Ruff (#17643) 2024-09-02 12:39:04 +01:00
test_visibility.py Include user membership on events (#17282) 2024-06-13 21:45:54 +00:00
unittest.py Cleanup Python 3.8 leftovers (#17967) 2025-02-10 16:53:24 +00:00
utils.py Cleanup Python 3.8 leftovers (#17967) 2025-02-10 16:53:24 +00:00