Commit Graph

3 Commits

Author SHA1 Message Date
Glenn Thompson 10a6799e29 fix: replace r-simple-rate sliding-window with fixed-window rate limiter
The upstream r-simple-rate tax-rate updates the timestamp on every request,
preventing the window from ever resetting while polling is active. This
caused 429 errors on all API endpoints during normal browser usage.

limiter.lisp:
- Add fixed-window-check that uses proper fixed windows (timestamp only
  resets when window expires, not on every request)
- Rewrite define-page-with-limit and define-api-with-limit to call
  fixed-window-check directly, bypassing rate:with-limitation entirely
- Immune to Radiance module reload ordering (no monkey-patches)

frontend-partials.lisp:
- Bump now-playing, now-playing-inline, now-playing-json rate limits
  from 10/1s to 120/60s to accommodate normal polling intervals

parenscript/front-page.lisp:
- Normalize channel-name polling from 10s to 15s (matches stream-player)
2026-04-17 17:55:31 -04:00
glenneth 55eafa943f Fix rate limiter corruption: cleanup negative amounts on startup
The r-simple-rate library has a bug where rate limit counters can go
negative and never reset. This happens because the reset condition
only triggers when amount >= 0, so negative amounts are permanently
stuck.

This fix adds:
- cleanup-corrupted-rate-limits function to delete corrupted entries
- db:connected trigger to run cleanup automatically on startup

This prevents the 429 error loops that occurred when counters became
corrupted with large negative values.
2026-01-18 12:58:35 -05:00
Luis Pereira 8ae905a2c1 feat: add limit extension macros for define-page and define-api 2025-12-27 13:28:10 -05:00