From 37a3b761db483126d0d87329faa258d0b7692aff Mon Sep 17 00:00:00 2001 From: Glenn Thompson Date: Sat, 7 Mar 2026 19:01:04 +0300 Subject: [PATCH] Fix API rate limits causing 429 errors on polling endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - asteroid/stats/current: add explicit :limit 120 :timeout 60 (was default 60/60s) - now-playing, now-playing-inline, now-playing-json: change from :limit 10 :timeout 1 to :limit 30 :timeout 60 — the 1-second window was too aggressive and likely triggering r-simple-rate's negative-amount corruption bug These endpoints are polled every 5-30s by the player frame, admin dashboard, and popout player. With multiple tabs/frames sharing a session, the old limits were easily exceeded, producing 429 responses that cascaded into audio error events. --- asteroid.lisp | 2 +- frontend-partials.lisp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/asteroid.lisp b/asteroid.lisp index 07b0bfb..0b19d22 100644 --- a/asteroid.lisp +++ b/asteroid.lisp @@ -1438,7 +1438,7 @@ ;;; Listener Statistics API Endpoints -(define-api-with-limit asteroid/stats/current () () +(define-api-with-limit asteroid/stats/current () (:limit 120 :timeout 60) "Get current listener count from recent snapshots" (with-error-handling (let ((listeners (get-current-listeners))) diff --git a/frontend-partials.lisp b/frontend-partials.lisp index f30c14d..c71015c 100644 --- a/frontend-partials.lisp +++ b/frontend-partials.lisp @@ -64,7 +64,7 @@ ;; Normal auto-playlist mode (harmony-now-playing mount))) -(define-api-with-limit asteroid/partial/now-playing (&optional mount) (:limit 10 :timeout 1) +(define-api-with-limit asteroid/partial/now-playing (&optional mount) (:limit 30 :timeout 60) "Get Partial HTML with live now-playing status. Optional MOUNT parameter specifies which stream to get metadata from. Returns partial HTML with current track info." @@ -87,7 +87,7 @@ :connection-error t :stats nil)))))) -(define-api-with-limit asteroid/partial/now-playing-inline (&optional mount) (:limit 10 :timeout 1) +(define-api-with-limit asteroid/partial/now-playing-inline (&optional mount) (:limit 30 :timeout 60) "Get inline text with now playing info (for admin dashboard and widgets). Optional MOUNT parameter specifies which stream to get metadata from." (with-error-handling @@ -101,7 +101,7 @@ (setf (header "Content-Type") "text/plain") "Stream Offline"))))) -(define-api-with-limit asteroid/partial/now-playing-json (&optional mount) (:limit 10 :timeout 1) +(define-api-with-limit asteroid/partial/now-playing-json (&optional mount) (:limit 30 :timeout 60) "Get JSON with now playing info including track ID for favorites. Optional MOUNT parameter specifies which stream to get metadata from." ;; Register web listener for geo stats (keeps listener active during playback)