Merge pull request #251 from wv-opt-ai/patch-1

Fix cleanup on exception in sync_api __enter__
This commit is contained in:
daijro
2026-01-11 23:37:49 -06:00
committed by GitHub
+5 -1
View File
@@ -26,7 +26,11 @@ class Camoufox(PlaywrightContextManager):
def __enter__(self) -> Union[Browser, BrowserContext]:
super().__enter__()
self.browser = NewBrowser(self._playwright, **self.launch_options)
try:
self.browser = NewBrowser(self._playwright, **self.launch_options)
except camoufox.exceptions.InvalidProxy as e:
super().__exit__(camoufox.exceptions.InvalidProxy, e, None)
raise
return self.browser
def __exit__(self, *args: Any):