summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-05-18 12:03:30 +0100
committerGitHub <noreply@github.com>2024-05-18 12:03:30 +0100
commit52af16c56175160512420d8654ac558a1e5af541 (patch)
tree7c9a9e4dbae6265ebff3cb08809a6fbac7fcbfc6 /synapse
parentFederated Knocking Endpoints added (missing in Docu) (#17058) (diff)
downloadsynapse-52af16c56175160512420d8654ac558a1e5af541.tar.xz
Add a short sleep if the request is rate-limited (#17210)
This helps prevent clients from "tight-looping" retrying their request.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/ratelimiting.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/api/ratelimiting.py b/synapse/api/ratelimiting.py
index a73626bc86..a99a9e09fc 100644
--- a/synapse/api/ratelimiting.py
+++ b/synapse/api/ratelimiting.py
@@ -316,6 +316,10 @@ class Ratelimiter:
         )
 
         if not allowed:
+            # We pause for a bit here to stop clients from "tight-looping" on
+            # retrying their request.
+            await self.clock.sleep(0.5)
+
             raise LimitExceededError(
                 limiter_name=self._limiter_name,
                 retry_after_ms=int(1000 * (time_allowed - time_now_s)),