Repository navigation
修复取消单个请求导致共享 Sidecar 误重启 - #2909
Merged
jlcodes99 merged 1 commit intoOct 27, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
用户取消一个流式请求后,Sidecar 生成 HTTP 499、
errorCategory: client_canceled,但errorMessage仍是裸context canceled。现有 Rust 宿主的自动重启判断会将这段文字当作上游超时,重启共享 Sidecar,进而打断其他正在生成的请求。本机日志中一个小时内出现了 15 次
status=499, category=client_canceled触发的兜底重启。此次修复针对错误重启,不将首次网络断连也归因于这一问题。改动
在
requestUsageTracker.finalize的最终 HTTP 499 分支,将 usage 错误消息明确标记为client canceled,并保留原始详情。例如context canceled变为client canceled: context canceled。宿主已有对明确客户端取消消息的优先排除逻辑,因此现有宿主无需重新打包即可避免该误判。仍然记录请求失败、499 和
client_canceled,保留已产生的账号归属及 token 用量;502/504 上游故障消息和分类维持原处理。三个文件:一处实现、一个新增回归测试和一个已有断言更新。这是与现有宿主兼容的取消事件修复。Rust 重启分类器本身没有在本 PR 中改动。本 PR 独立于 #2871,不包含其子代理派单改动。
验证
acc057d1fbc7d85d0aae288fdd2bc73581493d1e。context canceled、broken pipe、空消息、先前上游失败后客户端最终取消,以及 token/账号保留和 502/504 上游故障不变。client_canceled、client canceled: context canceled;另一条返回匹配的随机标记并正常收到response.completed,Sidecar PID 保持不变。主程序及账号配置未改动。未将真实凭据、账号配置、二进制、数据库或原始会话记录提交到仓库。云端 CI 结果以 GitHub 实际运行状态为准。