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.

nit(downloaders): reword recovery-state comments — sequential instance use, cross-thread sharing unsupported (#7353)

LearningCircuitf28830eb62f8
diff --git a/src/local_deep_research/research_library/downloaders/html.py b/src/local_deep_research/research_library/downloaders/html.py
index 18d9334085..06639cac4a 100644
--- a/src/local_deep_research/research_library/downloaders/html.py
+++ b/src/local_deep_research/research_library/downloaders/html.py
@@ -334,11 +334,14 @@ class HTMLDownloader(BaseDownloader):
as a warning rather than an error, since the caller handles it.
"""
# Fresh per-fetch recovery state. Cleared on entry so a stale stash
- # from an earlier fetch (or another thread sharing this downloader)
- # can never leak into this one; consumption additionally requires
- # the stashed request URL to match (see _consume_recovery), which
- # makes a cross-thread race benign (lost recovery, never wrong
- # content).
+ # from an earlier fetch can never leak into this one; consumption
+ # additionally requires the stashed request URL to match (see
+ # _consume_recovery). The stash fields are unsynchronized instance
+ # state: downloader instances are used sequentially (e.g. per-request
+ # construction in fetch_and_extract, or sequential consumption of
+ # one shared instance in batch_fetch_and_extract) — cross-thread
+ # sharing of one instance is unsupported, and the URL-match guard
+ # does not make it safe (see _consume_recovery).
self._recovery_kind: Optional[str] = None
self._recovery_payload: Optional[bytes | str] = None
self._recovery_url: Optional[str] = None
@@ -646,8 +649,15 @@ class HTMLDownloader(BaseDownloader):
or ``"text"`` (str), or ``(None, None, None)``. Single-use: the
stash is cleared on a URL match so each fetch consumes at most its
own bytes. A mismatch (stale stash from an earlier fetch) is left
- alone and reported as absent, which makes sharing one downloader
- across threads benign (lost recovery, never wrong content).
+ alone and reported as absent. The stash fields are unsynchronized
+ instance state and downloader instances are used sequentially
+ (per-request construction, or sequential consumption of one shared
+ instance); sharing one instance across threads is unsupported. The
+ URL-match guard does not make such sharing safe: the request URL is
+ recorded when a fetch starts, not when the stash is written, and
+ the non-200 and unexpected-content-type returns do not clear the
+ stash. If one instance is shared anyway, a request can lose its own
+ recovery or receive another request's recovered content.
"""
if getattr(self, "_recovery_payload", None) is None:
return None, None, None