fix: XHR timeout 30с + ontimeout — не висеть бесконечно на загрузке
Deploy drhider / validate (push) Waiting to run

This commit is contained in:
2026-07-14 10:24:55 +04:00
parent 79cd25a762
commit b6dac6f2bd
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ if _sys_path_root not in sys.path:
sys.path.insert(0, _sys_path_root) sys.path.insert(0, _sys_path_root)
# Версия приложения (меняется при изменениях) # Версия приложения (меняется при изменениях)
VERSION = "0.0.18" VERSION = "0.0.19"
def create_app(): def create_app():
+2
View File
@@ -172,6 +172,7 @@ async function uploadFiles() {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', '/api/upload'); xhr.open('POST', '/api/upload');
xhr.timeout = 30000; // 30 сек — не висеть бесконечно
xhr.upload.onprogress = function(e) { xhr.upload.onprogress = function(e) {
if (e.lengthComputable) { if (e.lengthComputable) {
const pct = Math.round(e.loaded / e.total * 100); const pct = Math.round(e.loaded / e.total * 100);
@@ -195,6 +196,7 @@ async function uploadFiles() {
} }
}; };
xhr.onerror = function() { reject(new Error('Сеть')); }; xhr.onerror = function() { reject(new Error('Сеть')); };
xhr.ontimeout = function() { reject(new Error('Таймаут 30с')); };
const fd = new FormData(); const fd = new FormData();
fd.append('files', f, f.name); fd.append('files', f, f.name);
if (currentSid) fd.append('session', currentSid); if (currentSid) fd.append('session', currentSid);