From 606cc3d398b50dad05649caed6337787b93fbd36 Mon Sep 17 00:00:00 2001 From: Pandyo Date: Fri, 5 Jun 2026 18:28:14 +0900 Subject: [PATCH] fix: dynamic rag --- .../scenario/playwright_dynamic_harness.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/embedding/scenario/playwright_dynamic_harness.py b/embedding/scenario/playwright_dynamic_harness.py index 3a84cd7b..15928394 100644 --- a/embedding/scenario/playwright_dynamic_harness.py +++ b/embedding/scenario/playwright_dynamic_harness.py @@ -719,6 +719,27 @@ def _install_target_seed_init_script(self) -> None: self._init_script_installed = True def _wait_for_service_worker(self, timeout_ms: int = 5000) -> bool: + # Content-script-only MV3 extensions (manifest without background.service_worker) + # never register a service worker. Once launch_persistent_context has loaded the + # extension, it is loaded — the content script runs when a matching page is + # navigated. Block here only for extensions that actually declare a worker; + # otherwise extension_loaded stays False forever and the run aborts at the + # extension_not_loaded gate. + if ( + self._execution.get("extension_background_type") != "service_worker" + and self._context is not None + and bool(self._execution.get("extension_context_launched", False)) + ): + self._execution["service_worker_count"] = 0 + self._execution["service_worker_urls"] = [] + self._execution["service_worker_ready"] = False + self._execution["extension_loaded"] = True + self._execution["extension_load_mode"] = "content_script_only" + prior_err = self._execution.get("extension_load_error") + if prior_err in {"playwright_sync_in_async_loop", "extension_service_worker_not_started_headless_mode_possible"}: + self._execution["extension_load_warning"] = str(prior_err or "") + self._execution["extension_load_error"] = "" + return True deadline = time.time() + (max(timeout_ms, 0) / 1000.0) while time.time() < deadline: workers = [] @@ -2188,6 +2209,10 @@ def close(self) -> dict: except Exception as exc: cleanup_errors.append(f"remove_temp_dir_failed:{exc}") self._tmp_dirs.clear() + # The unpacked extension dir was just removed above; drop the cached root so the + # next _ensure_context re-extracts from the zip instead of pointing at a deleted + # path (which would surface as manifest_not_found on every scenario after the first). + self._extension_root = None if not had_user_data_tmp: self._execution["cleanup_removed_user_data_dir_not_applicable"] = True if not had_unpacked_tmp: