fix(playwright): filter unsupported context options in persistent browser#1796
Merged
vdusek merged 7 commits intoapify:masterfrom Mar 27, 2026
Merged
Conversation
…wser This addresses issue apify#1784 by dynamically filtering options passed to launch_persistent_context and providing a warning log for ignored options like storage_state.
Pijukatel
requested changes
Mar 16, 2026
Collaborator
Pijukatel
left a comment
There was a problem hiding this comment.
Hello, thanks for the PR. Please see my comments; maybe we can use this approach on a different level.
…owserController Moving the validation logic from the browser instance to its controller as suggested by the reviewer. This improves user experience by raising TypeError for typos and nonsensical arguments while still providing helpful warnings for valid but incompatible cross-mode options like storage_state in persistent contexts. Also fixed dependency management in pyproject.toml.
Contributor
Author
|
Hello! Thank you for the detailed feedback. I've refactored the validation logic into
New unit tests cover both the warning and error scenarios. Ready for another look! |
Ran ruff formatter to fix CI lint error.
vdusek
requested changes
Mar 19, 2026
Removed browserforge and playwright from core dependencies in pyproject.toml as they belong in optional dependencies. Refactored Playwright signature cache in _playwright_browser_controller.py to load lazily via lru_cache rather than at module import time, preventing overhead when Playwright is not used.
Pijukatel
reviewed
Mar 23, 2026
Collaborator
Pijukatel
left a comment
There was a problem hiding this comment.
Thanks for the changes, and apologies for the delayed review. Just a few small comments, and I think it will be ready.
Pijukatel
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #1784, where PlaywrightCrawler would crash when passing context options (like storage_state) that are unsupported by Playwright's launch_persistent_context method.
Changes:
Implemented dynamic argument filtering in PlaywrightPersistentBrowser.new_context using inspect. signature.
Added a warning log to guide users when options are filtered out, suggesting the use of incognito pages as an alternative.
Added a unit test in
tests/unit/browsers/test_playwright_browser.py
to verify the fix and prevent regressions.
Fixes #1784