[Bug]: Post-navigation page operations have no timeout, and page cleanup is skipped on task cancellation — pages can leak and crawls can hang forever
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Start in async_crawler_strategy.py at the post-navigation operations and the cleanup finally block, then inspect browser_adapter.py and browser_manager.py for timeout behavior. Reproduce the busy-page hang and cancellation path described in the issue. Done means post-navigation work is bounded by page_timeout and cancelled tasks still close their pages.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Found while investigating #2202 (Docker containers accumulating renderer processes for weeks). Two related defects in async_crawler_strategy.py make it possible for a crawl to hang indefinitely and for its page to never be closed.
1. Nothing after navigation has a timeout
page_timeout only bounds page.goto() (async_crawler_strategy.py:762-764). Every page interaction after navigation is an un-timed call into the page's JS engine:
- overlay/consent removal —
remove_overlay_elements(:1550) - body-visibility check,
css_selectorextraction (:1102), image-dimension updates page.content()(:1115)- shadow-DOM flattening, iframe processing, user
js_code
The adapter is a plain pass-through to page.evaluate (browser_adapter.py:61-65), which has no timeout in Playwright. The repo never calls set_default_timeout except inside if self.config.accept_downloads: (browser_manager.py:1215-1217) — and default timeouts would not cover evaluate anyway. Only scan_full_page is wrapped in asyncio.wait_for.
A page whose main thread goes busy after DOMContentLoaded (bad loop, broken ad script, hostile page) therefore hangs the crawl forever, holding its page (= one renderer process) open. Verified with a page that starts a busy loop right after DCL: navigation succeeds, then arun() never returns, far past page_timeout.
2. The page-closing finally doesn't survive cancellation
The cleanup block (async_crawler_strategy.py:1216-1231) guards with except Exception. asyncio.CancelledError is a BaseException, so a task cancelled during the first await in that block (release_page_with_context) propagates out and page.close() is never reached — the page and its context refcount leak. Reachable from dispatcher/stream teardown paths that cancel in-flight tasks.
Impact
In long-lived processes (the Docker server's browser pool, any SDK user reusing a crawler), leaked pages accumulate indefinitely. Combined with the launch flags that disable background throttling, each leaked page also burns CPU forever. This is the core mechanism behind the multi-week renderer accumulation in #2202.
Proposed fix
- Wrap the post-navigation phase (or at minimum every
evaluate/content()call) inasyncio.wait_forwith a budget derived frompage_timeout, so a crawl always terminates. - Make the cleanup
finallycancellation-safe: catchBaseException(re-raisingCancelledErrorafter the page is closed) or shield the close.
- Lingua principale
- Python
- Stelle
- 85.4k
- Fork
- 8.9k
- Merge medio
- 5g 13h
- PR unite (30g)
- 28
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di unclecode/crawl4ai
-
[Bug]: crwl always bypasses the cache, -c cache_mode=enabled is ignoredForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta🐞 Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: whitespace-only inline elements are removed from cleaned_html, merging words in raw_markdown (prose, not only <pre>/<code>)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta⚙ Done 🐞 Bug 🥸 - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
unclecode/crawl4ai#2328 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: HTTP crawler puts proxy credentials into the URL unencodedForse di nuovo libera @omarbounawarapy l’ha presa 12 giorni fa e non c’è nessuna pull request aperta. Aperta⚙ Done 🐞 Bug 🥸 - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
unclecode/crawl4ai#2326 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Same PDF gives different markdown on each run when batch_size > 1 (threads share current_page_number)Forse già presa @Kylinny l’ha presa 13 giorni fa. Aperta⚙ Done 🐞 Bug 🥸 - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
unclecode/crawl4ai#2319 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Reusing BFSDeepCrawlStrategy leaks the previous crawl's max_pages budget into a fresh runForse di nuovo libera @nightcityblade l’ha presa 14 giorni fa e non c’è nessuna pull request aperta. Aperta⚙ Done 🐞 Bug 📌 Root caused 🥸 - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
unclecode/crawl4ai#2309 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di unclecode/crawl4ai
Issue simili
-
[Bug]: LangGraph Store sync put bypasses namespace validationForse già presa @ktz03 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
volcengine/OpenViking#6050 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunkForse già presa @rodricksz4h5 l’ha presa oggi. Apertaarea/streaming comp/gateway P2 type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#138245 ·
I maintainer di solito rispondono entro 1 giorno
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS stepForse già presa @github-actions l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
correction metadata
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 68/100
acl-org/acl-anthology#10378 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom nameForse già presa @12YYCCYY16 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
prowler-cloud/prowler#13033 ·
I maintainer di solito rispondono entro 1 giorno