fix: make the aiodns resolver opt-in and pin aiodns to 3.6.1 (#28242)
Since v0.11.0 shipped aiodns, aiohttp silently switched every outbound request from the OS resolver to c-ares. On some Windows hosts the bundled c-ares 1.34.6 (pycares 5) discovers only 127.0.0.1:53 as nameserver, so every external provider lookup fails (#28013). In Docker the long-lived c-ares channel intermittently stops resolving container names while Docker's embedded DNS keeps answering, which wipes the Ollama model list and fails all in-flight chats with a misleading "Model not found" (#28215). This restores the pre-0.11 ThreadedResolver (OS resolver) by default and gates the c-ares path behind a new env var, AIOHTTP_CLIENT_ASYNC_DNS_RESOLVER, off by default. The event-loop DNS perf improvement is now opt-in for deployments whose resolver setup is known to work with c-ares, instead of a process-wide side effect of the package being installed. aiodns is also downgraded and pinned to 3.6.1 (pycares<5), the last release before the broken c-ares 1.34.6 build, so opting in does not hit the Windows regression. The hardcoded AsyncResolver in the Mistral OCR loader now follows the same switch. Simply removing aiodns instead was not an option because opting in would then be impossible, and #28215 showed the Docker failure is c-ares itself, not aiodns 4.x.
This commit is contained in:
@@ -602,6 +602,18 @@ SEARXNG_CLIENT_KEY_FILE = os.getenv('SEARXNG_CLIENT_KEY_FILE', '').strip()
|
||||
# When False (default), outbound HTTP requests do not follow 3xx redirects.
|
||||
AIOHTTP_CLIENT_ALLOW_REDIRECTS = os.getenv('AIOHTTP_CLIENT_ALLOW_REDIRECTS', 'False').lower() == 'true'
|
||||
|
||||
# Opt-in c-ares DNS resolution (aiodns). Off by default: c-ares breaks name
|
||||
# resolution in some environments (#28013, #28215). Must run before any
|
||||
# TCPConnector is constructed.
|
||||
AIOHTTP_CLIENT_ASYNC_DNS_RESOLVER = os.getenv('AIOHTTP_CLIENT_ASYNC_DNS_RESOLVER', 'False').lower() == 'true'
|
||||
|
||||
if not AIOHTTP_CLIENT_ASYNC_DNS_RESOLVER:
|
||||
import aiohttp
|
||||
|
||||
aiohttp.DefaultResolver = aiohttp.resolver.ThreadedResolver # for plugin code
|
||||
aiohttp.resolver.DefaultResolver = aiohttp.resolver.ThreadedResolver
|
||||
aiohttp.connector.DefaultResolver = aiohttp.resolver.ThreadedResolver
|
||||
|
||||
# Optional User-Agent override for outbound web-loader fetches. When set,
|
||||
# SafeWebBaseLoader sends this value instead of the default python-requests UA
|
||||
# which is aggressively blocked by Cloudflare, Wikipedia, and similar services.
|
||||
|
||||
@@ -477,7 +477,6 @@ class MistralLoader:
|
||||
keepalive_timeout=60, # Increased keepalive for connection reuse
|
||||
enable_cleanup_closed=True,
|
||||
force_close=False, # Allow connection reuse
|
||||
resolver=aiohttp.AsyncResolver(), # Use async DNS resolver
|
||||
)
|
||||
|
||||
timeout = aiohttp.ClientTimeout(
|
||||
|
||||
Reference in New Issue
Block a user