From 593d18089b790b8dffd96f6ab23974a3f548eae8 Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sun, 6 Sep 2026 01:08:25 +0200 Subject: [PATCH] fix: wait longer for history due to slow audio upload --- worker.mjs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/worker.mjs b/worker.mjs index bd4f14f..739831a 100644 --- a/worker.mjs +++ b/worker.mjs @@ -177,19 +177,28 @@ async function processJob({ jsonPath, job, expectedVideoPath, targetFormat }) { // 4. Render-Knopf drücken console.log('🚀 Starte Export-Prozess...'); - await page.click('#btnStartExport'); + await page.evaluate(() => { + document.getElementById('btnStartExport').click(); + }); // 5. Überwache den History API Endpunkt - console.log('⏳ Warte auf den Abschluss des Renderings...'); + console.log('⏳ Warte auf den Abschluss des Renderings (Audio-Upload an Server läuft...)'); let isDone = false; let lastStatus = ''; - await new Promise(r => setTimeout(r, 4000)); + // Wir pollen die History, bis ein Job auftaucht (Upload kann etwas dauern!) + let history = []; + let attempts = 0; + while (history.length === 0 && attempts < 30) { + await new Promise(r => setTimeout(r, 2000)); + try { + const historyRes = await fetch(`${VIZ_URL}/api/export/history`); + history = await historyRes.json(); + } catch(e) {} + attempts++; + } - const historyRes = await fetch(`${VIZ_URL}/api/export/history`); - const history = await historyRes.json(); - - if (history.length === 0) throw new Error('Kein Export-Job in History gefunden'); + if (history.length === 0) throw new Error('Kein Export-Job in History gefunden (Timeout nach 60s)'); const sessionId = history[0].id; console.log(`🔗 Session ID ermittelt: ${sessionId}`);