From 7d38fdf601bb10381277e0cbb9ac470b3a4bbca4 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 9 May 2026 23:32:38 +0200 Subject: [PATCH] fix: add 90s timeout to Spotify resolve fetch, prevent infinite spinner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Frontend fetch to /api/spotify/resolve had no timeout — if the backend stalled (Spotify API slow or unreachable), the spinner would never stop. Also caps the health check at 5s so loadSpotifyImporter can't hang. Co-Authored-By: Claude Sonnet 4.6 --- src/spotify.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/spotify.js b/src/spotify.js index 709d428..d408e85 100644 --- a/src/spotify.js +++ b/src/spotify.js @@ -16,7 +16,7 @@ export async function loadSpotifyImporter() { if (S.cfg.backendUrl) { try { - const h = await fetch(`${S.cfg.backendUrl}/api/health`).then(r => r.json()); + const h = await fetch(`${S.cfg.backendUrl}/api/health`, { signal: AbortSignal.timeout(5000) }).then(r => r.json()); if (!h.spotify?.configured) { const input = document.getElementById('spotify-link-input'); if (input) { @@ -63,6 +63,7 @@ export async function resolveSpotifyLink() { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url }), + signal: AbortSignal.timeout(90000), }); if (!res.ok) { const err = await res.json().catch(() => ({})); @@ -74,6 +75,10 @@ export async function resolveSpotifyLink() { if (data.skippedLocal > 0) toast(`${data.skippedLocal} lokale Datei(en) übersprungen (kein Stream verfügbar)`); _renderSpotifyPreview(data); } catch(e) { + if (e.name === 'TimeoutError' || e.name === 'AbortError') { + inner.innerHTML = `
Zeitüberschreitung — der Server hat nicht rechtzeitig geantwortet. Läuft das Backend?
`; + return; + } if (e.message === 'EDITORIAL_PLAYLIST') { inner.innerHTML = `
💡 Editorial Playlist erkannt