fix/limiter-accuracy-and-deps #1

Merged
tbdsux merged 10 commits from fix/limiter-accuracy-and-deps into main 2026-11-02 04:16:07 +00:00
Owner
No description provided.
Replace httpx with httpx2, which Starlette's test client now expects.
Clients can forge the header to get a fresh counter on every request. Apps
behind a proxy must now have the server resolve the client address, for
example with uvicorn --forwarded-allow-ips.
Retry-After was a millisecond timestamp and is now a delay in seconds. Reset
times compared bucket timestamps to a monotonic clock, which was wrong for
wall-clock backends, so they now use the bucket's own clock. A 429 reports the
rate that failed. Also removes the unused exception handler from RateLimiter.
A callback that returned instead of raising let the request through in the
dependency and caused a 500 in the middleware. Both now send the default 429.
Different identifiers could collapse to one name and share a counter, and long
paths produced unbounded names. Most names change, so existing SQLite and Redis
counters start fresh.
Async Redis clients returned 500s because the factory stored the unawaited
bucket, and async clocks crashed once a bucket was cached.
Every unique identifier kept a bucket forever, so clients could grow memory by
requesting random paths. Empty buckets hold no state and are now dropped about
once a minute. Async buckets are not evicted yet.
The multiprocess bucket started one Manager process per identifier and now
shares one. SQLite with no db_path now uses one temp file. Redis and Postgres
options now apply to every identifier, and Postgres no longer drops them.
The simple examples now use the plain in-memory bucket.
ci: run on ubuntu-latest with Forgejo checkout action
All checks were successful
CI / ci (push) Successful in 36s
CI / ci (pull_request) Successful in 14s
098599a7d4
codeberg-tiny is a Codeberg runner label and the repo now lives on a self-hosted Forgejo. Use the short checkout reference at its latest major version, v7.
tbdsux merged commit 9374ba4da6 into main 2026-11-02 04:16:07 +00:00
tbdsux deleted branch fix/limiter-accuracy-and-deps 2026-11-02 04:16:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tbdsux/fapi-limiter!1
No description provided.