The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(browser): only signal a failed launch's Chromium while it still runs
Teknium17044ad1ce3b
diff --git a/tests/tools/test_browser_launcher.py b/tests/tools/test_browser_launcher.pyindex 3552fc1a2be..4c84e09fbb1 100644--- a/tests/tools/test_browser_launcher.py+++ b/tests/tools/test_browser_launcher.py@@ -210,6 +210,20 @@ def test_launch_failure_reports_the_exit_and_leaves_nothing_registered(tmp_path,assert launcher.get_browser("broken") is None[email protected]("posix")+def test_a_browser_that_exited_during_startup_is_not_signalled(tmp_path, caplog, fake_chromium):+ """A Chromium that died during startup is only reaped: signalling its pid would be refused as recycled+ and logged as a WARNING that blames the wrong thing."""+ import logging+ broken = tmp_path / "exits-at-once"+ broken.write_text(f"#!{sys.executable}\nimport sys\nsys.exit(21)\n")+ broken.chmod(0o755)+ caplog.set_level(logging.WARNING)+ browser, err = launcher.launch_chromium("dies", executable=str(broken), env=dict(os.environ), timeout=10)+ assert browser is None and "exited with code 21" in err+ assert not [r for r in caplog.records if r.levelno >= logging.WARNING], [r.getMessage() for r in caplog.records]++def _write_orphan_record(records: Path, pid: int, udd: str) -> Path:dead_owner = subprocess.Popen([sys.executable, "-c", "pass"])dead_owner.wait()diff --git a/tools/browser_launcher.py b/tools/browser_launcher.pyindex 1e803529e71..4ab28350a05 100644--- a/tools/browser_launcher.py+++ b/tools/browser_launcher.py@@ -433,7 +433,8 @@ def _launch_owned(key: str, executable: str, udd: str, *, ephemeral: bool, packastart_time = _start_time(proc.pid)found, err = _wait_for_devtools(proc, udd, time.monotonic() + _launch_timeout(timeout))if found is None:- _terminate(proc.pid, start_time, proc)+ if proc.poll() is None: # one that already exited is reaped by poll(); its pid is no longer ours+ _terminate(proc.pid, start_time, proc)if ephemeral:shutil.rmtree(udd, ignore_errors=True)return None, err