Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add fetch timeout with AbortController (#1994)

LearningCircuit8caaf8c39022
diff --git a/src/local_deep_research/web/static/js/services/api.js b/src/local_deep_research/web/static/js/services/api.js
index 779685a8f1..59f6f51a5c 100644
--- a/src/local_deep_research/web/static/js/services/api.js
+++ b/src/local_deep_research/web/static/js/services/api.js
@@ -28,20 +28,26 @@ function getApiUrl(path) {
}
/**
- * Generic fetch with error handling
+ * Generic fetch with error handling and timeout support
* @param {string} url - The URL to fetch
* @param {Object} options - Fetch options
+ * @param {number} [options.timeout=30000] - Request timeout in milliseconds (default: 30s)
* @returns {Promise<any>} The parsed response data
*/
async function fetchWithErrorHandling(url, options = {}) {
+ const { timeout = 30000, ...fetchOptions } = options;
+ const controller = new AbortController();
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
+
try {
const csrfToken = getCsrfToken();
const response = await fetch(url, {
- ...options,
+ ...fetchOptions,
+ signal: controller.signal,
headers: {
'Content-Type': 'application/json',
...(csrfToken ? { 'X-CSRFToken': csrfToken } : {}),
- ...(options.headers || {})
+ ...(fetchOptions.headers || {})
}
});
@@ -54,8 +60,13 @@ async function fetchWithErrorHandling(url, options = {}) {
// Parse the response
return await response.json();
} catch (error) {
+ if (error.name === 'AbortError') {
+ throw new Error('Request timed out');
+ }
SafeLogger.error('API Error:', error);
throw error;
+ } finally {
+ clearTimeout(timeoutId);
}
}