fix: DrHider — better JS error handling, progress messages, timeout
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-06-29 15:14:01 +04:00
parent b081042f98
commit 7f9f7c0e62
+9 -4
View File
@@ -121,16 +121,21 @@ function render() {
BTN.onclick = async () => { BTN.onclick = async () => {
if (!files.length) return; if (!files.length) return;
BTN.disabled = true; BTN.disabled = true;
setStatus('progress', '⏳ Обработка...'); setStatus('progress', '⏳ Отправка на сервер...');
const fd = new FormData(); files.forEach(f => fd.append('files', f)); const fd = new FormData(); files.forEach(f => fd.append('files', f));
try { try {
const r = await fetch('/api/drhider', { method:'POST', body:fd }); setStatus('progress', '⏳ Обработка (может занять до минуты)...');
if (!r.ok) throw new Error(await r.text()); const r = await fetch('/api/drhider', { method:'POST', body:fd, signal:AbortSignal.timeout(300000) });
if (!r.ok) {
const txt = await r.text();
throw new Error(txt);
}
const blob = await r.blob(); const blob = await r.blob();
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'drhider_output.zip'; a.click(); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'drhider_output.zip'; a.click();
setStatus('done', '✅ Готово! ZIP скачан.'); setStatus('done', '✅ Готово! ZIP скачан.');
} catch(e) { } catch(e) {
setStatus('error', '❌ ' + e.message); setStatus('error', '❌ ' + (e.name === 'TimeoutError' ? 'Сервер не ответил за 5 минут' : e.message || 'Неизвестная ошибка'));
console.error('DrHider error:', e);
} }
BTN.disabled = false; BTN.disabled = false;
}; };