From 9c04426950abb9aae9c73bbc357317a55cac6fc4 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 21 Mar 2026 15:35:18 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20response=20body=20double-?= =?UTF-8?q?read=20regression=20+=20updater=20JSON=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hosters.js apiGet(): fixed regression from v2.3.8 where res.json() consumed the body, making res.text() return empty on parse failure. Now reads as text first, then parses JSON (matching VOE fix pattern). - updater.js fetchJson(): same fix — read text first, parse JSON, show actual server response in error message on failure. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/hosters.js | 4 ++-- lib/updater.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/hosters.js b/lib/hosters.js index 367e857..c4ac3c3 100644 --- a/lib/hosters.js +++ b/lib/hosters.js @@ -281,11 +281,11 @@ async function apiGet(url, signal) { signal: controller.signal, redirect: 'follow' }); + const text = await res.text(); let data; try { - data = await res.json(); + data = JSON.parse(text); } catch { - const text = await res.text().catch(() => ''); throw new Error(`API-Antwort war kein JSON (HTTP ${res.status}): ${(text || '').slice(0, 200)}`); } diff --git a/lib/updater.js b/lib/updater.js index 1dfbd7c..3f9b725 100644 --- a/lib/updater.js +++ b/lib/updater.js @@ -65,7 +65,12 @@ async function fetchJson(url, signal) { signal: controller.signal, redirect: 'follow' }); - return await res.json(); + const text = await res.text(); + try { + return JSON.parse(text); + } catch { + throw new Error(`Update-Server Antwort war kein JSON (HTTP ${res.status}): ${text.slice(0, 200)}`); + } } finally { clearTimeout(timeout); if (signal) signal.removeEventListener('abort', onAbort);