Fix Global Timeout and JS Error Logs
This commit is contained in:
@@ -97,16 +97,27 @@
|
|||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
// Remove loading
|
|
||||||
const loadingEl = document.getElementById(loadingId);
|
|
||||||
if (loadingEl) loadingEl.remove();
|
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
// Remove loading
|
||||||
|
const loadingEl = document.getElementById(loadingId);
|
||||||
|
if (loadingEl) loadingEl.remove();
|
||||||
|
|
||||||
addMessage('assistant', data.answer);
|
addMessage('assistant', data.answer);
|
||||||
} else {
|
} else {
|
||||||
addMessage('error', data.answer || 'Error communicating with server.');
|
// Try to parse error JSON, but handle HTML error pages (like 504)
|
||||||
|
let errorMsg = "Error communicating with server.";
|
||||||
|
try {
|
||||||
|
const data = await response.json();
|
||||||
|
if (data.detail) errorMsg = data.detail;
|
||||||
|
else if (data.answer) errorMsg = data.answer;
|
||||||
|
} catch (e) {
|
||||||
|
errorMsg = `Server Error: ${response.status} ${response.statusText}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadingEl = document.getElementById(loadingId);
|
||||||
|
if (loadingEl) loadingEl.remove();
|
||||||
|
addMessage('error', errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ location / {
|
|||||||
# Timeouts
|
# Timeouts
|
||||||
proxy_connect_timeout 60s;
|
proxy_connect_timeout 60s;
|
||||||
proxy_send_timeout 60s;
|
proxy_send_timeout 60s;
|
||||||
proxy_read_timeout 60s;
|
proxy_read_timeout 300s;
|
||||||
|
|
||||||
# Buffering
|
# Buffering
|
||||||
proxy_buffering on;
|
proxy_buffering on;
|
||||||
|
|||||||
Reference in New Issue
Block a user