From 0780db55e1298e73178077ec0bdc65cd534faa8d Mon Sep 17 00:00:00 2001 From: UncleCode Date: Fri, 29 Nov 2024 21:12:19 +0800 Subject: [PATCH] fix: handle errors during image dimension updates in AsyncPlaywrightCrawlerStrategy --- crawl4ai/async_crawler_strategy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crawl4ai/async_crawler_strategy.py b/crawl4ai/async_crawler_strategy.py index e5316187..cc7f3993 100644 --- a/crawl4ai/async_crawler_strategy.py +++ b/crawl4ai/async_crawler_strategy.py @@ -920,7 +920,11 @@ class AsyncPlaywrightCrawlerStrategy(AsyncCrawlerStrategy): }); } """ - await page.evaluate(update_image_dimensions_js) + try: + await page.wait_for_load_state() + await page.evaluate(update_image_dimensions_js) + except Exception as e: + raise RuntimeError(f"Error updating image dimensions ACS-UPDATE_IMAGE_DIMENSIONS_JS: {str(e)}") # Wait a bit for any onload events to complete await page.wait_for_timeout(100)