~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(unified-search): clear the abort controller on the short-query early return (#6895)
LearningCircuite56d4f450122
diff --git a/src/local_deep_research/web/static/js/pages/unified_search.js b/src/local_deep_research/web/static/js/pages/unified_search.jsindex 670144ad7a..e2ef7c9ef2 100644--- a/src/local_deep_research/web/static/js/pages/unified_search.js+++ b/src/local_deep_research/web/static/js/pages/unified_search.js@@ -315,6 +315,14 @@ async function runUnifiedSearch() {const myId = ++unifiedSearchRunId;if (query.length < window.SemanticSearch.MIN_QUERY_LENGTH) {+ // This return bypasses the try/finally below — the only other+ // cleanup site for the controller reference we just installed.+ // Nothing is in flight, so drop it here (mirroring the input+ // handler's null-out) or the reference lingers until some later+ // search aborts the stale controller as a no-op (#5580).+ if (unifiedSearchAbortController === controller) {+ unifiedSearchAbortController = null;+ }clearUnifiedSearchNotice();showUnifiedSearchIdleState();return;diff --git a/tests/js/pages/unified-search.test.js b/tests/js/pages/unified-search.test.jsindex 1dabb5a5cd..183947d5e6 100644--- a/tests/js/pages/unified-search.test.js+++ b/tests/js/pages/unified-search.test.js@@ -316,6 +316,39 @@ describe('input invalidation', () => {vi.useRealTimers();}});++ it('leaves no dangling controller when a short query skips the try/finally', async () => {+ // A mode switch calls runUnifiedSearch unconditionally. With a+ // query below MIN_QUERY_LENGTH that call installs a fresh+ // AbortController and then returns BEFORE the try block, so the+ // finally that clears the module-level reference never runs+ // (#5580). Detected indirectly: a stale controller would be+ // aborted as a no-op by the NEXT search's guard, so abort must+ // never fire here.+ const dom = makeDom();+ hook.setDomRefs(dom);+ hook.setUnifiedSearchMode('text');+ hook.setupUnifiedSearchListeners();+ globalThis.safeFetch = vi.fn().mockResolvedValue({+ json: () => Promise.resolve({ success: true, results: [] }),+ });++ const abortSpy = vi.spyOn(AbortController.prototype, 'abort');++ try {+ dom.input.value = 'a'; // below MIN_QUERY_LENGTH (2)+ hook.setUnifiedSearchMode('semantic'); // runs runUnifiedSearch++ dom.input.value = 'a real query now';+ await hook.runUnifiedSearch();++ expect(globalThis.safeFetch).toHaveBeenCalledOnce();+ // No in-flight request was ever superseded: nothing to abort.+ expect(abortSpy).not.toHaveBeenCalled();+ } finally {+ abortSpy.mockRestore();+ }+ });});describe('failure recovery', () => {