mirror of
https://github.com/element-hq/synapse.git
synced 2026-05-12 02:14:44 +00:00
e62175ac44
⏺ All 9 ratelimit tests pass when run together. Here's a summary of the fix: Root cause: _advance_time in make_request was jumping fake time to the next pending sleep's wake time. This fired looping call sleeps (5s+ intervals), which re-scheduled themselves, creating a chain of 5s+ time jumps per request. With 10+ requests, fake time advanced 50+ seconds, fully refilling ratelimit token buckets. Fix (two parts): 1. tests/server.py _advance_time: Changed from jumping to next pending sleep to advancing in tiny 1ms increments. At 1ms per event loop iteration, even thousands of iterations only add a few seconds of fake time — too little to meaningfully refill ratelimit buckets (0.2 tokens/sec × a few seconds ≈ 1 token). 2. tests/server.py clock auto-detection: Added if clock is None and hasattr(reactor, '_clock'): clock = reactor._clock so that callers like RestHelper (which don't pass clock=) still get fake time advancement. Without this, requests that hit ratelimit pauses (clock.sleep()) would hang forever.