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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(browser): reap browser children when their worker crashes
rubenluetke10-beep960d3ee987d6
diff --git a/jarvis/society/browser/live.py b/jarvis/society/browser/live.pyindex 298a977f12..66675702fa 100644--- a/jarvis/society/browser/live.py+++ b/jarvis/society/browser/live.py@@ -188,6 +188,17 @@ class LiveSession:while chunk := await self.proc.stderr.read(8192):self.stderr_tail = (self.stderr_tail + chunk.decode("utf-8", "replace"))[-4000:]+ async def watch_exit(self) -> None:+ """Reap descendants even if they keep the dead worker's pipes open.++ asyncio Process.wait() also waits for pipe EOF, so it cannot be the+ crash detector here. returncode is updated by the OS process watcher+ independently of inherited pipe handles.+ """+ while self.proc.returncode is None: # noqa: ASYNC110 — wait() depends on inherited pipe EOF+ await asyncio.sleep(0.1)+ self.tree.close()+async def close(self) -> None:if not self.closed:try:@@ -302,6 +313,7 @@ class LiveSessions:session.readers = [asyncio.create_task(session.read()),asyncio.create_task(session.drain_stderr()),+ asyncio.create_task(session.watch_exit()),]try:result = await session.command(diff --git a/tests/contract/test_browser_live.py b/tests/contract/test_browser_live.pyindex e8bc96be8b..84bff0ff58 100644--- a/tests/contract/test_browser_live.py+++ b/tests/contract/test_browser_live.py@@ -660,3 +660,30 @@ async def test_login_profile_survives_restart_and_stays_with_its_agent(live, sitassert ("/account?other", False) in PageHandler.profile_requestsfinally:await live.close()+++async def test_crashed_worker_recovers_without_touching_the_other_agent(live):+ import psutil++ one = SimpleNamespace(agent_id="crash", model="", browser_allowed_domains=[])+ two = SimpleNamespace(agent_id="survivor", model="", browser_allowed_domains=[])+ try:+ old, _ = await live.subscribe(one)+ survivor, _ = await live.subscribe(two)+ children = await asyncio.to_thread(+ lambda: psutil.Process(old.proc.pid).children(recursive=True)+ )+ old.proc.kill() # Only this disposable test worker; containment owns its children.+ await asyncio.wait_for(old.proc.wait(), 10)+ await asyncio.wait_for(old.readers[0], 10)+ assert old.closed+ recovered, frames = await live.subscribe(one)+ while (await asyncio.wait_for(frames.get(), 5))["kind"] != "frame":+ pass # Drain initial state until real recovered pixels arrive.+ assert recovered.proc.pid != old.proc.pid+ assert await live.ensure(two) is survivor+ assert not survivor.closed and survivor.proc.returncode is None+ _, alive = await asyncio.to_thread(psutil.wait_procs, children, timeout=10)+ assert not alive+ finally:+ await live.close()