fix: fail fast on Spotify 429 instead of retrying into timeout

Retrying with wait times (23s + 60s + 60s) exceeded the 120s global
timeout and showed a generic timeout error. Now returns immediately
with a RATE_LIMITED error and shows the user how long to wait.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-11 00:05:41 +02:00
1 parent fbb00baa11
commit 859f4a458a
2 files changed
+25 -18

No files matched your search

+12
View File
@@ -68,6 +68,7 @@ export async function resolveSpotifyLink() {
if (!res.ok) {
const err = await res.json().catch(() => ({}));
if (err.error === 'EDITORIAL_PLAYLIST') throw new Error('EDITORIAL_PLAYLIST');
if (err.error === 'RATE_LIMITED') throw new Error(`RATE_LIMITED:${err.retryAfter || 30}`);
throw new Error(err.error || err.message || `HTTP ${res.status}`);
}
const data = await res.json();
@@ -79,6 +80,17 @@ export async function resolveSpotifyLink() {
inner.innerHTML = `<div style="color:var(--danger);padding:16px;background:var(--surface);border-radius:10px">Zeitüberschreitung — der Server hat nicht rechtzeitig geantwortet. Läuft das Backend?</div>`;
return;
}
if (e.message.startsWith('RATE_LIMITED:')) {
const secs = parseInt(e.message.split(':')[1], 10) || 30;
const mins = secs >= 60 ? `${Math.ceil(secs / 60)} Min.` : `${secs}s`;
inner.innerHTML = `<div style="color:var(--text);padding:16px;background:var(--surface);border-radius:10px;border-left:3px solid var(--warning,#f59e0b)">
<div style="font-weight:600;margin-bottom:6px">⏳ Spotify Rate Limit</div>
<div style="font-size:13px;line-height:1.5;color:var(--text2)">
Spotify hat zu viele Anfragen erhalten. Bitte in ca. <strong>${mins}</strong> erneut versuchen.
</div>
</div>`;
return;
}
if (e.message === 'EDITORIAL_PLAYLIST') {
inner.innerHTML = `<div style="padding:16px;background:var(--surface);border-radius:10px;border-left:3px solid #1DB954">
<div style="font-weight:600;margin-bottom:10px;color:#1DB954">💡 Editorial Playlist erkannt</div>