Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(browser): tolerate Chrome's transient port-file lock

rubenluetke10-beep6ea283e12e59
diff --git a/jarvis/society/browser/live_runner.py b/jarvis/society/browser/live_runner.py
index 5e5ca02b56..67d95b748e 100644
--- a/jarvis/society/browser/live_runner.py
+++ b/jarvis/society/browser/live_runner.py
@@ -188,8 +188,9 @@ class Worker:
if not 0 < port < 65536:
raise ValueError("Invalid browser debugging port")
break
- except (FileNotFoundError, IndexError, ValueError):
- # A missing or partially written file is normal during launch.
+ except (FileNotFoundError, PermissionError, IndexError, ValueError):
+ # Chromium can briefly hold an exclusive Windows handle
+ # while publishing this file; the startup deadline still applies.
await asyncio.sleep(0.05)
cdp_url = f"http://127.0.0.1:{port}"
self.browser_args = {"cdp_url": cdp_url, "allowed_domains": args.get("allowed_domains")}
diff --git a/tests/contract/browser_pointer_probe.py b/tests/contract/browser_pointer_probe.py
index d17755d5bc..86f71d13d2 100644
--- a/tests/contract/browser_pointer_probe.py
+++ b/tests/contract/browser_pointer_probe.py
@@ -16,16 +16,31 @@ async def main():
events = []
live_runner.emit = lambda kind, **data: events.append({"kind": kind, **data})
worker = live_runner.Worker()
+ read_text = Path.read_text
+ port_lock_retries = 0
+
+ def temporarily_locked(path, *args, **kwargs):
+ nonlocal port_lock_retries
+ if path.name == "DevToolsActivePort" and port_lock_retries < 2:
+ port_lock_retries += 1
+ raise PermissionError("Chromium is publishing its port file")
+ return read_text(path, *args, **kwargs)
+
try:
profile = Path(sys.argv[2])
- await worker.start(
- {
- "profile_dir": str(profile),
- "workspace": str(profile / "workspace"),
- "executable": sys.argv[1],
- "allowed_domains": [],
- }
- )
+ Path.read_text = temporarily_locked
+ try:
+ await worker.start(
+ {
+ "profile_dir": str(profile),
+ "workspace": str(profile / "workspace"),
+ "executable": sys.argv[1],
+ "allowed_domains": [],
+ }
+ )
+ finally:
+ Path.read_text = read_text
+ assert port_lock_retries == 2
assert worker.browser is None # First pixels need no agent engine.
await worker.ensure_browser()
await worker.page.goto("about:blank")