Skip to content

fix: convert page_timeout ms to seconds for aiohttp (#1894)#1895

Open
hafezparast wants to merge 1 commit intounclecode:developfrom
hafezparast:fix/maysam-http-timeout-unit-mismatch-1894
Open

fix: convert page_timeout ms to seconds for aiohttp (#1894)#1895
hafezparast wants to merge 1 commit intounclecode:developfrom
hafezparast:fix/maysam-http-timeout-unit-mismatch-1894

Conversation

@hafezparast
Copy link
Copy Markdown
Contributor

Summary

page_timeout is in milliseconds (Playwright convention, default 60000), but AsyncHTTPCrawlerStrategy._handle_http passed it directly to aiohttp.ClientTimeout(total=...) which expects seconds. This made the default timeout 60,000 seconds (16.7 hours) instead of 60 seconds.

Fixes #1894

The Bug

# page_timeout = 60000 (ms, meaning 60 seconds)
timeout = ClientTimeout(
    total=config.page_timeout,  # aiohttp gets 60000 SECONDS = 16.7 hours
    connect=10,      # these are correctly in seconds
    sock_read=30     # these are correctly in seconds
)

The Fix

timeout_sec = (config.page_timeout / 1000) if config.page_timeout else self.DEFAULT_TIMEOUT
timeout = ClientTimeout(total=timeout_sec, ...)

Changes

  • crawl4ai/async_crawler_strategy.py: 1 line — divide page_timeout by 1000 before passing to ClientTimeout
  • tests/test_http_timeout_unit_1894.py: 8 tests verifying the conversion

Test plan

  • 8 unit tests passing
  • Default 60000ms → 60s verified
  • Custom 5000ms → 5s verified
  • Fallback to DEFAULT_TIMEOUT (30s) when page_timeout=0

🤖 Generated with Claude Code

unclecode#1894)

page_timeout is in milliseconds (Playwright convention, default 60000ms),
but AsyncHTTPCrawlerStrategy passed it directly to aiohttp.ClientTimeout
which expects seconds. This made the default timeout 60,000 seconds
(16.7 hours) instead of 60 seconds, effectively disabling timeouts
for HTTP mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant