From b65b3ee6b9462067f21231fb9400588626e8cd79 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Fri, 30 Jan 2026 15:01:36 +0100 Subject: [PATCH] fix: Prevent mutation of default URL patterns list in block_requests When url_patterns was None, the code assigned it to the module-level _DEFAULT_BLOCK_REQUEST_URL_PATTERNS constant and then called extend() on it, permanently mutating the shared default list. This caused extra_url_patterns to accumulate across all subsequent calls that used the default patterns. Fixed by creating a copy of the list before extending it. Co-Authored-By: Claude Opus 4.5 --- src/crawlee/crawlers/_playwright/_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/crawlee/crawlers/_playwright/_utils.py b/src/crawlee/crawlers/_playwright/_utils.py index 956b269e13..153d50e204 100644 --- a/src/crawlee/crawlers/_playwright/_utils.py +++ b/src/crawlee/crawlers/_playwright/_utils.py @@ -88,8 +88,7 @@ async def block_requests( url_patterns: List of URL patterns to block. If None, uses default patterns. extra_url_patterns: Additional URL patterns to append to the main patterns list. """ - url_patterns = url_patterns or _DEFAULT_BLOCK_REQUEST_URL_PATTERNS - + url_patterns = list(url_patterns or _DEFAULT_BLOCK_REQUEST_URL_PATTERNS) url_patterns.extend(extra_url_patterns or []) browser_type = page.context.browser.browser_type.name if page.context.browser else 'undefined'