diff --git a/lib/updater.js b/lib/updater.js index f935a4e..ac38810 100644 --- a/lib/updater.js +++ b/lib/updater.js @@ -179,10 +179,27 @@ async function installUpdate(onProgress) { let downloadedBytes = 0; const chunks = []; + const DOWNLOAD_STALL_MS = 45000; + let stallTimer = null; const reader = res.body.getReader(); while (true) { if (signal.aborted) throw new Error('Abgebrochen'); - const { done, value } = await reader.read(); + let chunk; + try { + chunk = await Promise.race([ + reader.read(), + new Promise((_, reject) => { stallTimer = setTimeout(() => reject(new Error('__STALL__')), DOWNLOAD_STALL_MS); }) + ]); + } catch (e) { + if (e && e.message === '__STALL__') { + try { activeAbort.abort(); } catch {} + throw new Error('Download hängt — seit 45 s keine Daten (Netzwerk/Server überlastet). Bitte laufende Uploads stoppen und erneut versuchen.'); + } + throw e; + } finally { + if (stallTimer) { clearTimeout(stallTimer); stallTimer = null; } + } + const { done, value } = chunk; if (done) break; chunks.push(value); downloadedBytes += value.length; diff --git a/main.js b/main.js index ea5308e..1add692 100644 --- a/main.js +++ b/main.js @@ -2294,6 +2294,7 @@ ipcMain.handle('app:check-updates', async () => { }); ipcMain.handle('app:install-update', () => { + try { if (uploadManager) uploadManager.cancel(); } catch {} installUpdate((progress) => { safeSend('app:update-progress', progress); }).catch((err) => {