{"record":{"id":"f788bae851abeaad","repo":"unclecode/crawl4ai","slug":"request-timed-out-str-e","errorCode":null,"errorMessage":"Request timed out: {str(e)}","messagePattern":"Request timed out: (.+?)","errorType":"exception","errorClass":"ConnectionTimeoutError","httpStatus":null,"severity":"error","filePath":"crawl4ai/async_crawler_strategy.py","lineNumber":2780,"sourceCode":"                        if not encoding:\n                            detection_result = await asyncio.to_thread(chardet.detect, content.tobytes())\n                            encoding = detection_result['encoding'] or 'utf-8'\n                        html = content.tobytes().decode(encoding, errors='replace')\n\n                    result = AsyncCrawlResponse(\n                        html=html,\n                        response_headers=response_headers,\n                        status_code=response.status,\n                        redirected_url=str(response.url),\n                        downloaded_files=downloaded_files,\n                    )\n\n                    await self.hooks['after_request'](result)\n                    return result\n\n            except aiohttp.ServerTimeoutError as e:\n                await self.hooks['on_error'](e)\n                raise ConnectionTimeoutError(f\"Request timed out: {str(e)}\")\n                \n            except aiohttp.ClientConnectorError as e:\n                await self.hooks['on_error'](e)\n                raise ConnectionError(f\"Connection failed: {str(e)}\")\n                \n            except aiohttp.ClientError as e:\n                await self.hooks['on_error'](e)\n                raise HTTPCrawlerError(f\"HTTP client error: {str(e)}\")\n            \n            except asyncio.exceptions.TimeoutError as e:\n                await self.hooks['on_error'](e)\n                raise ConnectionTimeoutError(f\"Request timed out: {str(e)}\")\n            \n            except Exception as e:\n                await self.hooks['on_error'](e)\n                raise HTTPCrawlerError(f\"HTTP request failed: {str(e)}\")\n\n    async def crawl(","sourceCodeStart":2762,"sourceCodeEnd":2798,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_crawler_strategy.py#L2762-L2798","documentation":"Raised when aiohttp raises ServerTimeoutError (or asyncio.TimeoutError) during an HTTP-mode crawl. The exception is converted to ConnectionTimeoutError with the original message. This reflects the server accepting the connection but failing to respond in time, or the overall request deadline expiring.","triggerScenarios":"Slow endpoints that exceed aiohttp's timeout; the default ClientTimeout elapsed on large downloads; servers that hang on keep-alive connections; proxies that stall. Distinct from ClientConnectorError (connection never established).","commonSituations":"Large file/page downloads with default timeouts; overloaded target servers; network paths with high latency; misconfigured proxy timeouts shorter than the target's response time.","solutions":["Increase the request timeout in the HTTP crawler's session config (BrowserConfig timeout options / aiohttp ClientTimeout).","Retry with backoff: server timeouts are frequently transient.","For large downloads, stream or raise total timeout; for flaky keep-alive, lower keepalive_timeout or use force_close."],"exampleFix":"// before\nresult = await crawler.arun(url)  # hangs then raises ConnectionTimeoutError\n\n// after\nimport aiohttp\nfrom crawl4ai.async_crawler_strategy import ConnectionTimeoutError\nfor attempt in range(3):\n    try:\n        result = await crawler.arun(url)\n        break\n    except ConnectionTimeoutError:\n        await asyncio.sleep(2 ** attempt)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from crawl4ai.async_crawler_strategy import ConnectionTimeoutError\n\nfor attempt in range(3):\n    try:\n        result = await crawler.arun(url)\n        break\n    except ConnectionTimeoutError:\n        await asyncio.sleep(2 ** attempt)\nelse:\n    raise","preventionTips":["Raise aiohttp total timeout for slow endpoints","Retry timeouts with exponential backoff","Monitor per-host latency to size timeouts"],"tags":["timeout","http-crawler","network"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}