fix(browser): clean up owned browser daemons on shutdown after cancellation

Shutdown cleanup must not depend on active record.session capability,
which is cleared on cancellation. Guard cleanup by socket directory
presence so all owned daemons are terminated.
This commit is contained in:
Alexandre Teixeira
2026-10-02 18:54:09 +01:00
parent 896e1f8233
commit cc14151d10
2 changed files with 29 additions and 2 deletions
+1 -2
View File
@@ -2708,8 +2708,7 @@ async def shutdown_private_browser_sessions() -> None:
_ACTIVE_BROWSER_SESSIONS.discard(session)
from src.browser_identity import _REGISTRY
for record in tuple(_REGISTRY.values()):
session = record.session
if session is not None and session.observation.daemon.owned():
if record.env and "AGENT_BROWSER_SOCKET_DIR" in record.env:
browser_lifecycle.force_cleanup(Path(record.env["AGENT_BROWSER_SOCKET_DIR"]), record.key,
method="shutdown", pid_alive=lambda pid: _process_is_alive(pid))
record.invalidate()