Fix API rate limits causing 429 errors on polling endpoints

- 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.
This commit is contained in:
Glenn Thompson 2026-03-07 19:01:04 +03:00
parent 2aab912b5d
commit 37a3b761db
2 changed files with 4 additions and 4 deletions

View File

@ -1438,7 +1438,7 @@
;;; Listener Statistics API Endpoints ;;; 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" "Get current listener count from recent snapshots"
(with-error-handling (with-error-handling
(let ((listeners (get-current-listeners))) (let ((listeners (get-current-listeners)))

View File

@ -64,7 +64,7 @@
;; Normal auto-playlist mode ;; Normal auto-playlist mode
(harmony-now-playing mount))) (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. "Get Partial HTML with live now-playing status.
Optional MOUNT parameter specifies which stream to get metadata from. Optional MOUNT parameter specifies which stream to get metadata from.
Returns partial HTML with current track info." Returns partial HTML with current track info."
@ -87,7 +87,7 @@
:connection-error t :connection-error t
:stats nil)))))) :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). "Get inline text with now playing info (for admin dashboard and widgets).
Optional MOUNT parameter specifies which stream to get metadata from." Optional MOUNT parameter specifies which stream to get metadata from."
(with-error-handling (with-error-handling
@ -101,7 +101,7 @@
(setf (header "Content-Type") "text/plain") (setf (header "Content-Type") "text/plain")
"Stream Offline"))))) "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. "Get JSON with now playing info including track ID for favorites.
Optional MOUNT parameter specifies which stream to get metadata from." Optional MOUNT parameter specifies which stream to get metadata from."
;; Register web listener for geo stats (keeps listener active during playback) ;; Register web listener for geo stats (keeps listener active during playback)