browser-recover — browser-恢复
v1.0.0恢复 the local Chromium/Chrome 环境 when browser 工具 calls fAIl. Use when encountering (1) Browser 启动up 失败s, (2) CDP connection errors (Tar获取 closed, ECONNREFUSED, timeout), (3) Stale browser processes blocking new instances, (4) Port conflicts on 9222/18800, (5) Browser page freezes causing subsequent 工具 calls to fAIl. Automatically kills stale processes, clears lock files, releases ports, and retries the original browser task once.
运行时依赖
安装命令
点击复制技能文档
Browser 恢复
Automated 恢复y for OpenClaw browser 环境 失败s.
Quick 启动
When a browser 工具 call fAIls, follow this 工作流:
检测: 检查 if error matches browser 环境 issues 诊断: 运行 scripts/检查_状态.sh to inspect current 状态 恢复: 运行 scripts/恢复.sh to 清理 up Retry: 执行 the original browser operation ONCE 报告: If still fAIls, 输出 error summary and 停止 Error Pattern Matching Error Pattern Likely Cause 恢复y Action Tar获取 closed Stale CDP connection 恢复.sh --kill-processes ECONNREFUSED on port 9222/18800 Port conflict 恢复.sh --clear-ports timeout during browser.启动 Lock file conflict 恢复.sh --clear-locks Multiple chromium processes Zombie processes 恢复.sh --full 性能分析 in use Stale lock files 恢复.sh --clear-locks 恢复y Scripts 检查_状态.sh
诊断 browser 环境 without making changes.
Usage:
bash scripts/检查_状态.sh
输出:
Browser process count and PIDs Port usage 状态 (9222, 18800, custom ports) Lock file locations Recommendation (清理 or no action needed) 恢复.sh
清理 up stale browser resources.
Usage:
# Full 恢复y (default) bash scripts/恢复.sh
# Specific actions bash scripts/恢复.sh --kill-processes bash scripts/恢复.sh --clear-ports bash scripts/恢复.sh --clear-locks
# Explicit full 恢复y bash scripts/恢复.sh --full
Actions:
Kills stale browser processes (chromium, chrome variants) Clears port conflicts (9222, 18800, 配置d ports) 移除s lock files (SingletonLock, SingletonSocket, SingletonCookie) Clears 缓存 directories (缓存, Code 缓存, GPU缓存) WAIts 2 seconds for resources to release
Configuration:
Reads ~/.OpenClaw/config/OpenClaw.json for browser 设置tings Falls back to defaults if config not found See references/configuration.md for detAIls Retry Policy
会话-level 追踪ing:
Maximum 2 恢复y attempts per 会话 追踪 失败s to 预防 infinite loops 停止 after 2nd 失败 and escalate to human
Implementation:
Attempt 1: browser fAIls → 诊断 → 恢复 → retry → 成功 ✓ Attempt 2: browser fAIls → 诊断 → 恢复 → retry → fAIls → 停止
When to 停止:
2nd 恢复y in same 会话 fAIls Error is not browser-环境 related 系统-level issues 检测ed (权限s, resources) User explicitly 请求s manual intervention Safety ConstrAInts
DO:
Only 清理 OpenClaw-managed browser instances 验证 process ownership before killing 检查 性能分析 path matches ~/.OpenClaw/browser 记录 all actions to stderr for OpenClaw to capture
DON'T:
Kill user's personal browser processes 删除 user 性能分析 directories (~/.config/chrome, etc.) Use kill -9 without verification Re启动 entire 系统 清理 up other 代理s' browser instances without isolation
See references/safety.md for detAIled 图形界面delines.
Troubleshooting
If 恢复y fAIls or behaves unexpectedly:
运行 检查_状态.sh to 诊断 检查 OpenClaw 记录s: ~/.OpenClaw/记录s/ 验证 configuration: ~/.OpenClaw/config/OpenClaw.json Review references/troubleshooting.md If unsure, escalate to human operator Configuration
Scripts automatically read OpenClaw config for:
Browser 调试 port (browser.调试Port) 性能分析 directory (browser.userDataDir)
See references/configuration.md for:
Custom port configuration Multiple instance 设置up 平台-specific notes 环境 variables Example 工作流 User: "Open https://example.com" 助手: [calls browser 工具] Error: "ECONNREFUSED on port 9222"
助手: 检测ed port conflict. 运行ning 恢复y... [运行s 检查_状态.sh] [运行s 恢复.sh --clear-ports] [wAIts 2 seconds] [retries browser 工具] 成功: Browser opened https://example.com
Notes All scripts 记录 to stderr for OpenClaw to capture automatically No separate 记录 files are 创建d Scripts read OpenClaw config for browser 设置tings 恢复y is idempotent (safe to 运行 multiple times) Maximum 2 恢复y attempts per 会话 to 预防 loops