diff --git a/skyvern/webeye/browser_factory.py b/skyvern/webeye/browser_factory.py index 3c6eb7f5..6d4c9872 100644 --- a/skyvern/webeye/browser_factory.py +++ b/skyvern/webeye/browser_factory.py @@ -200,6 +200,7 @@ class BrowserState: url: str | None = None, proxy_location: ProxyLocation | None = None, task_id: str | None = None, + workflow_run_id: str | None = None, ) -> None: if self.pw is None: LOG.info("Starting playwright") @@ -216,6 +217,7 @@ class BrowserState: url=url, proxy_location=proxy_location, task_id=task_id, + workflow_run_id=workflow_run_id, ) self.browser_context = browser_context self.browser_artifacts = browser_artifacts @@ -276,23 +278,30 @@ class BrowserState: url: str | None = None, proxy_location: ProxyLocation | None = None, task_id: str | None = None, + workflow_run_id: str | None = None, ) -> Page: if self.page is not None: return self.page try: - await self.check_and_fix_state(url=url, proxy_location=proxy_location, task_id=task_id) + await self.check_and_fix_state( + url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id + ) except Exception as e: error_message = str(e) if "net::ERR" not in error_message: raise e await self.close_current_open_page() - await self.check_and_fix_state(url=url, proxy_location=proxy_location, task_id=task_id) + await self.check_and_fix_state( + url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id + ) assert self.page is not None if not await BrowserContextFactory.validate_browser_context(self.page): await self.close_current_open_page() - await self.check_and_fix_state(url=url, proxy_location=proxy_location, task_id=task_id) + await self.check_and_fix_state( + url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id + ) assert self.page is not None return self.page diff --git a/skyvern/webeye/browser_manager.py b/skyvern/webeye/browser_manager.py index 446c8f54..e007fd78 100644 --- a/skyvern/webeye/browser_manager.py +++ b/skyvern/webeye/browser_manager.py @@ -84,7 +84,9 @@ class BrowserManager: # The URL here is only used when creating a new page, and not when using an existing page. # This will make sure browser_state.page is not None. - await browser_state.get_or_create_page(url=url, proxy_location=workflow_run.proxy_location) + await browser_state.get_or_create_page( + url=url, proxy_location=workflow_run.proxy_location, workflow_run_id=workflow_run.workflow_run_id + ) self.pages[workflow_run.workflow_run_id] = browser_state return browser_state