
yumusbandClaude Opus 4.7
e0c9fc5b25
fix: 修复 Agent 卡死不触发重连的问题
Agent 在连接断开后完全卡死 17 小时,根因分析如下:
1. 并发写竞争:pingLoop 直接使用 rawConn.WriteControl 与 metricsLoop
的 safeConn.WriteJSON 竞争同一个 gorilla websocket 内部锁
2. 连接写失败被吞掉:outboundWriter.WriteJSON 写失败时返回 nil,
metricsLoop 感知不到连接错误,不会触发重连
3. 采集器无超时保护:任何采集器阻塞都会冻结整个 metricsLoop
修复:
- safeConn 新增 WriteControl 方法,pingLoop 改用 safeConn 写入
- outboundWriter.WriteJSON 写失败时返回真实错误
- collectAndSendAllMetrics 增加 30 秒全局超时保护
- 连接写失败视为连接异常,返回错误触发重连
- 新增采集耗时监控日志(耗时超过 500ms 时记录)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 14:43:06 +08:00
..
2026-04-20 14:43:06 +08:00
2025-11-25 20:21:31 +08:00
2025-11-30 11:38:51 +08:00