Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: sweep orphaned sockets in sessions command

ShawnPanae9897975410c
diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.py
index 88f6780df..2fd00552a 100755
--- a/browser_use/skill_cli/main.py
+++ b/browser_use/skill_cli/main.py
@@ -801,6 +801,12 @@ def _handle_sessions(args: argparse.Namespace) -> int:
sessions.append(entry)
+ # Sweep orphaned sockets that have no corresponding live PID file
+ live_names = {s['name'] for s in sessions}
+ for sock_file in home_dir.glob('*.sock'):
+ if sock_file.stem not in live_names:
+ sock_file.unlink(missing_ok=True)
+
if args.json:
print(json.dumps({'sessions': sessions}))
else: