LiveAgent
LiveAgent copied to clipboard
[Bug] Gateway 的 hello 应答可能被控制队列的帧抢先,TestV2KBrainPlanningRelaysWithoutDesktop 偶发失败
Affected area
Gateway (agent-gateway) — v2 WebSocket browser handshake
Version or commit
main @ 2c0476ac5(CI #2253 首次运行失败,重跑通过)
Environment
GitHub Actions Gateway job(ubuntu)
Steps to reproduce
偶发。CI 运行 https://github.com/Stack-Cairn/LiveAgent/actions/runs/44474146658 的首次尝试:
--- FAIL: TestV2KBrainPlanningRelaysWithoutDesktop (0.00s)
v2_kbrain_planning_test.go:47: v2 hello reply = ... AgentId:"planning-kbrain", Payload:(*gatewayv2.WebServerFrame_HistorySyncStatus) ..., want ok hello
Expected behavior
浏览器连接握手后收到的第一帧一定是 hello 应答。
Actual behavior
第一帧偶尔是 HistorySyncStatus。
原因:握手成功后 hello 应答只是入队到数据队列(FrameResponse),而心跳和历史恢复状态走控制队列。写泵在两条都就绪的队列之间用 select 随机取帧,写泵协程被调度得晚时,随后入队的控制帧会先写出。配置了 K-brain 的 Gateway 在启动后第一次后端请求返回时广播历史同步状态,正好落在首次握手前后。
Logs / screenshots
见上面的 CI 日志。
Pre-submit checklist
- [x] I searched existing issues and pull requests and found no duplicates.
- [x] This is not a security vulnerability (report those privately via Security Advisories).