From d0875a51b2f07766b339b34a580d4e6e9fab348d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 23 Aug 2026 11:44:41 +0200 Subject: Handle Strava rate limiting with abort, retry time and daily usage display Strava sync for 167 rides exceeds the 100/15-min read limit (2 calls per ride). Previously a 429 was treated as a skipped ride, so every remaining ride also failed silently. Now GetJSON returns a typed RateLimitError with RetryAfter computed from Retry-After/Date and X-RateLimit headers (15-min window resets at :00/:15/:30/:45, daily at midnight UTC) and tracks Read/Overall usage. syncRides aborts on 429 with partial progress instead of skipping, and handleSync emits an SSE error with retry time, daily usage vs limit and structured rateLimit snapshot; progress and complete events also carry the snapshot for the UI to display. Frontend shows Read daily/15-min usage in progress details and on completion. --- web/frontend/types.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/frontend/types.d.ts') diff --git a/web/frontend/types.d.ts b/web/frontend/types.d.ts index 3c2a918..6ff3dcf 100644 --- a/web/frontend/types.d.ts +++ b/web/frontend/types.d.ts @@ -124,14 +124,30 @@ export interface AnalyticsPoint { movingHours: number; } +export interface RateLimit { + limit15: number; + usage15: number; + limitDaily: number; + usageDaily: number; +} + +export interface RateLimitSnapshot { + read: RateLimit; + overall: RateLimit; +} + export interface SyncProgress { total: number; completed: number; imported: number; skipped: number; + rateLimit?: RateLimitSnapshot; } export interface SyncErrorEvent { message: string; progress?: SyncProgress; + retryAfter?: string; + isRateLimited?: boolean; + rateLimit?: RateLimitSnapshot; } -- cgit v1.3