diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc index 7abd602..7f6d7e1 100644 Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ diff --git a/app.py b/app.py index a31d7c9..f58828a 100644 --- a/app.py +++ b/app.py @@ -79,6 +79,7 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str): if REMOTE_DEBUGGING_ENABLED: import subprocess import glob + import urllib.request # Точный путь из контейнера CHROME_PATH = "/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome" @@ -114,41 +115,43 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str): "--no-first-run", "--no-default-browser-check", "--disable-extensions", - "--disable-popup-blocking", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage", - "--disable-software-rasterizer", - "--disable-setuid-sandbox", - "--disable-blink-features=AutomationControlled", "--headless", - "--disable-web-security", "about:blank" ] # Запускаем процесс process = subprocess.Popen( chrome_cmd, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL + stdout=subprocess.PIPE, + stderr=subprocess.PIPE ) - # Даем браузеру время запуститься и проверяем CDP - import time - import urllib.request + # Ждем пока Chrome запустится и CDP будет готов cdp_ready = False - for i in range(15): # Ждем до 15 секунд + for i in range(30): # Ждем до 30 секунд await asyncio.sleep(1) try: - response = urllib.request.urlopen(f"http://localhost:{REMOTE_DEBUGGING_PORT}/json/version", timeout=1) + response = urllib.request.urlopen( + f"http://localhost:{REMOTE_DEBUGGING_PORT}/json/version", + timeout=2 + ) if response.status == 200: cdp_ready = True break - except: + except Exception: pass if not cdp_ready: - raise RuntimeError(f"Chrome started but CDP not ready after 15s") + # Получаем логи Chrome + stdout, stderr = process.communicate(timeout=5) + raise RuntimeError( + f"Chrome started but CDP not ready after 30s.\n" + f"STDOUT: {stdout.decode()}\n" + f"STDERR: {stderr.decode()}" + ) # Подключаемся через CDP cdp_url = f"http://localhost:{REMOTE_DEBUGGING_PORT}"