aboutsummaryrefslogtreecommitdiff
path: root/web/frontend/types.d.ts
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 11:44:41 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 11:44:41 +0200
commitd0875a51b2f07766b339b34a580d4e6e9fab348d (patch)
tree2e03e2714afdbf81c05662edc511b0b8b04c7919 /web/frontend/types.d.ts
parentf7264b8f594859c1430bd13e765db03002842d38 (diff)
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.
Diffstat (limited to 'web/frontend/types.d.ts')
-rw-r--r--web/frontend/types.d.ts16
1 files changed, 16 insertions, 0 deletions
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;
}