Ionosphere.tv
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: respect rate limit reset header in PDS client

Instead of crashing on 429, waits until the ratelimit-reset time and
retries automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+9 -1
+9 -1
apps/ionosphere-appview/src/pds-client.ts
··· 22 22 for (let attempt = 0; attempt <= maxRetries; attempt++) { 23 23 try { 24 24 return await fn(); 25 - } catch (err) { 25 + } catch (err: any) { 26 26 lastError = err; 27 + // If rate limited, wait until the reset time 28 + if (err?.status === 429 && err?.headers?.["ratelimit-reset"]) { 29 + const resetAt = Number(err.headers["ratelimit-reset"]); 30 + const waitSec = Math.max(resetAt - Math.floor(Date.now() / 1000), 1); 31 + console.log(`Rate limited — waiting ${waitSec}s until reset...`); 32 + await delay(waitSec * 1000 + 1000); 33 + continue; 34 + } 27 35 if (attempt < maxRetries) { 28 36 const waitMs = Math.min(initialDelay * Math.pow(2, attempt), maxDelay); 29 37 await delay(waitMs);