{"record":{"id":"4abfeadd857d9ad4","repo":"langchain-ai/deepagents","slug":"download-of-url-exceeded-download-timeout-seco","errorCode":null,"errorMessage":"Download of {url} exceeded {_DOWNLOAD_TIMEOUT_SECONDS}s deadline","messagePattern":"Download of (.+?) exceeded (.+?)s deadline","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/managed_tools.py","lineNumber":569,"sourceCode":"    import time\n    import urllib.error\n    import urllib.request\n\n    deadline = time.monotonic() + _DOWNLOAD_TIMEOUT_SECONDS\n    with (\n        urllib.request.urlopen(url, timeout=_DOWNLOAD_TIMEOUT_SECONDS) as resp,  # noqa: S310  # fixed https GitHub release URL\n        dest.open(\"wb\") as fh,\n    ):\n        status = getattr(resp, \"status\", None)\n        if status is not None and status != 200:  # noqa: PLR2004  # HTTP 200 OK\n            msg = f\"Unexpected HTTP {status} response fetching {url}\"\n            raise urllib.error.URLError(msg)\n        while True:\n            if time.monotonic() > deadline:\n                msg = (\n                    f\"Download of {url} exceeded {_DOWNLOAD_TIMEOUT_SECONDS}s deadline\"\n                )\n                raise TimeoutError(msg)\n            chunk = resp.read(_DOWNLOAD_CHUNK_BYTES)\n            if not chunk:\n                break\n            fh.write(chunk)\n\n\ndef _sha256(path: Path) -> str:\n    \"\"\"Return the SHA-256 hex digest of `path`.\"\"\"\n    import hashlib\n\n    digest = hashlib.sha256()\n    with path.open(\"rb\") as fh:\n        for chunk in iter(lambda: fh.read(1 << 20), b\"\"):\n            digest.update(chunk)\n    return digest.hexdigest()\n\n\ndef _verify_sha256(path: Path, expected_hex: str) -> None:","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/managed_tools.py#L551-L587","documentation":"`_download_to` raises `TimeoutError` when downloading a managed tool (e.g. ripgrep) exceeds the fixed `_DOWNLOAD_TIMEOUT_SECONDS` deadline, measured with `time.monotonic()`. This prevents a stalled connection from hanging installation indefinitely.","triggerScenarios":"`_install_ripgrep_sync` triggering a download on a slow or throttled network, a stalled/stuck connection where `resp.read()` blocks, or a very large artifact on a low-bandwidth link (VPN, corporate proxy, CI runner with limited egress).","commonSituations":"Flaky Wi-Fi or satellite links; corporate proxies buffering slowly; CI runners in constrained regions; GitHub release CDN throttling.","solutions":["Retry the install when the network is faster (the operation is safe to rerun)","Pre-provision the tool manually so the download path is skipped, or point any configured mirror/download URL at a faster host","Check proxy/VPN throughput and disable throttling middleboxes; if a proxy is required, ensure it is configured for the process"],"exampleFix":"// before\n$ dcode install-tools   # times out on hotel Wi-Fi\n// after\n$ networksetup -setairportpower en0 off && networksetup -setairportpower en0 on  # reset link\n$ dcode install-tools     # retry once connection is stable\n// or pre-provision rg on PATH so no download is needed","handlingStrategy":"retry","validationCode":"import socket\n\n# quick reachability probe before starting the (deadline-bound) download\nhost = \"github.com\"\ntry:\n    socket.create_connection((host, 443), timeout=5).close()\nexcept OSError:\n    raise SystemExit(\"no network connectivity; fix connection before install\")","typeGuard":null,"tryCatchPattern":"try:\n    _install_ripgrep_sync()\nexcept TimeoutError as exc:\n    logger.warning(\"tool download too slow: %s; retrying once\", exc)\n    _install_ripgrep_sync()  # retry, or fall back to system rg if present","preventionTips":["Install managed tools on a stable connection, not captive-portal Wi-Fi","Configure proxy settings before first run so downloads use the fast path","Pre-provision rg on PATH to skip the download entirely"],"tags":["network","timeout","download"],"backgroundTag":"download-timeout","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}