fix(config): make body visibility timeout configurable - #2131
Conversation
|
@nightcityblade Thanks — approach looks right. Default stays 30000 so nobody's existing crawls change, and I checked the plumbing: Three things before merge:
Separate from this PR: even after it lands, the default path still spends 30 silent seconds on these pages. |
|
Thanks for the detailed review. Addressed in
Focused validation passes: 40 config tests and 38 trust-boundary tests. I kept the separate timeout-debug logging idea out of this PR as suggested. |
…se the harm was sized MAS shipped their raw client logs for the sweep (49-data/: 61,937 timing rows, 5,511 refusal rows, terminal outcomes). Their capture table prices every defect on our open list in the only unit that matters -- pages they lost: our 429s 29 captures (0.05% of 60,874 attempts) our 500s 156 captures (0.26%) render_defect 27 captures 86.1% stored; 95% of all their failures were the origin Across 175 hours, two requests failed hard at the wire. That is the bar seven task files failed. Not because the diagnoses were wrong -- most were right -- but because the thing being fixed is worth less than the regression risk of fixing it, and in three cases upstream is fixing it for us. Closed and moved to tasks/done/ unchanged, with the reasoning for each in tasks/done/post-sweep-closure-2026-08-17.md: - memory-guard-charges-reclaimable-page-cache: settled by two repos. Our `anon` moved +26 MB of 4,096 across 53 h; MAS's independent gauge +0.13 points. All three candidate fixes refuted or unsafe. max_browsers never refused once in 186,178 requests. - crawl-cost-is-idle-replicas-not-slow-renders: question answered. One config number took cost per 1,000 requests from $3.28 to $0.51. The fleet is at its floor and the remaining levers are MAS's. - the patchright permanent-class retry: upstream PR unclecode#2131 fixes the 30 s wait_for_selector("body") it depends on. Do not build what upstream ships. - static-mode-tls-impersonation, static-fallback-within-fence: static mode was used 0 times in 186,178 requests, confirmed from MAS's side. - blocked-host-retry-economy: premise refuted. On the 590 hosts crawled in both regimes the block rate is identical (2.75 vs 2.73/1k) and zero hosts went clean-then-blocked. The rise is composition -- dead-DNS went 0.22% -> 1.78%/day. - preflight-batch-endpoint: both sides already declined it. - cleaned-html-collapse-guard part 2: recovery works -- 43 rescued (~1.6M chars) against 10 unrecovered. Root-causing the rest is prospective. What survives is four items, each for a different reason, and none is a performance optimisation: the capacity gate (MAS's one explicit ask, and their 49-... section 1 is the argument -- our gauge sat in their logs for a fortnight because it was embedded in prose), the fixture-origin proxy gap (~12 lines, makes 67 existing tests measure the path production uses), the upstream PRs (reframed: our fork is +4,696 lines with ~2,375 on files upstream owns, and upstream is now editing api.py and server.py), and a one-word render_mode fix. tasks/README.md rewritten from scratch. Every item gives concern, evidence, why it matters and what the author is least sure of -- and deliberately no ordered checklist, because a step list narrows the implementing session's judgement and a fresh context re-deriving the diagnosis is what has caught nine consecutive task files being wrong. Two standing rules added: size the harm before opening the investigation, and research what is true this month. The consent problem turned out to be solved by the wider ecosystem in a way we had not noticed -- every maintained system hides rather than removes, and autoconsent's rule syntax has no remove() action at all -- which is what the upstream PR should now argue. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@nightcityblade thanks for your contribution :) |
Summary
Fixes #2129.
Add
CrawlerRunConfig.body_visibility_timeout, defaulting to the existing 30-second behavior, and use it for the body visibility check. This lets callers lower the ceiling for pages whose body remains hidden without changing the default crawl behavior. The value is included in config serialization and the untrusted-config allowlist, validated as a positive number, and capped at 60 seconds for untrusted Docker input.List of files changed and why
crawl4ai/async_configs.py- define, document, serialize, validate, allow, and cap the new configuration field.crawl4ai/async_crawler_strategy.py- pass the configured timeout to the body visibility wait.docs/md_v2/api/parameters.mdanddocs/md_v2/complete-sdk-reference.md- document the new public option.tests/test_config_defaults.py- cover the default and round trip, invalid values, the untrusted cap, and propagation intocsp_compliant_wait.How Has This Been Tested?
/tmp/crawl4ai-followup-venv/bin/python -m pytest tests/test_config_defaults.py -q— 40 passed, 1 existing warning./tmp/crawl4ai-followup-venv/bin/python -m pytest deploy/docker/tests/test_security_trust_boundary.py -q— 38 passed, 4 existing warnings./tmp/crawl4ai-followup-venv/bin/ruff check --isolated --select E9,F63,F7,F82 --ignore F821 crawl4ai/async_configs.py crawl4ai/async_crawler_strategy.py tests/test_config_defaults.py— passed. (F821is excluded because of the existingVirtualScrollConfigforward-reference finding inasync_crawler_strategy.py.)/tmp/crawl4ai-followup-venv/bin/python -m compileall -q crawl4ai/async_configs.py crawl4ai/async_crawler_strategy.py tests/test_config_defaults.py— passed.git diff --check— passed.Checklist: