From f9a8ea395046fc6e152c5e9c76508938b306348a Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 19 Mar 2026 08:44:31 +0100 Subject: [PATCH 1/2] fix(test): increase sleep margin in flaky recurring task test The test_execution test expected >= 3 calls with a 30ms delay but only slept 100ms, leaving ~10ms of headroom. On loaded CI runners, asyncio scheduling jitter caused only 2 calls, failing the assertion. Doubling the sleep to 200ms provides a comfortable margin. Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/unit/_utils/test_recurring_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/_utils/test_recurring_task.py b/tests/unit/_utils/test_recurring_task.py index 3dffa65011..d2ddd2d861 100644 --- a/tests/unit/_utils/test_recurring_task.py +++ b/tests/unit/_utils/test_recurring_task.py @@ -46,7 +46,7 @@ async def test_execution(function: AsyncMock, delay: timedelta) -> None: task = RecurringTask(function, delay) task.start() - await asyncio.sleep(0.1) # Wait enough for the task to execute a few times + await asyncio.sleep(0.2) # Wait enough for the task to execute a few times await task.stop() assert isinstance(task.func, AsyncMock) # To let type checker know that the function is a mock From 75863768a68f7e44d89f6baf23d061338db941a0 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 19 Mar 2026 08:49:14 +0100 Subject: [PATCH 2/2] fix(test): fix flaky adaptive playwright crawler timeout test On slow Windows CI, Playwright browser startup exceeded the 10s relaxed timeout, causing the browser fallback to fail. BasicCrawler then retried the request, and the retry's static crawl succeeded (using the mutated timeout), calling the static handler a second time. Fix: increase relaxed timeout to 120s for slow CI, and set max_request_retries=0 since the test validates fallback, not retries. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../test_adaptive_playwright_crawler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py b/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py index 7eed877112..b6f0289c02 100644 --- a/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py +++ b/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py @@ -579,7 +579,7 @@ async def test_adaptive_playwright_crawler_timeout_in_sub_crawler(test_urls: lis request_handler_timeout = timedelta(seconds=1) crawler = AdaptivePlaywrightCrawler.with_beautifulsoup_static_parser( - max_request_retries=1, + max_request_retries=0, rendering_type_predictor=static_only_predictor_no_detection, request_handler_timeout=request_handler_timeout, ) @@ -594,8 +594,8 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None: mocked_browser_handler() except AdaptiveContextError: mocked_static_handler() - # Relax timeout for the fallback browser request to avoid flakiness in test - crawler._request_handler_timeout = timedelta(seconds=10) + # Relax timeout for the fallback browser request to allow for slow browser startup on CI + crawler._request_handler_timeout = timedelta(seconds=120) # Sleep for time obviously larger than top crawler timeout. await asyncio.sleep(request_handler_timeout.total_seconds() * 3)