fix: prevent Dashboard crash on proxy TLS handshake disconnect - #60
Merged
wicm84266964 merged 1 commit intoSep 17, 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.
Change
修复内置 HTTPS 代理联网请求在 TLS 握手期间断开连接时,未处理的 socket
error事件导致整个 Dashboard 退出的问题。请求失败后继续监听 socket 错误,直到close才清理;网络失败仍会正常返回给调用方。发现和复现过程
131800c,版本 2.0.14),安装依赖并重新关联全局命令。Node.js 为 v24.13.0。ant-code dashboard,服务成功启动,但聊天过程中进程退出,报Unhandled 'error' event,错误对象为ECONNRESET,消息为Client network socket disconnected before secure TLS connection was established,发出事件的是TLSSocket。用户当时开启了代理。proxyHttpsRequest()建立 CONNECT 隧道后使用tls.connect(),由collectRawHttpResponse()接收响应。该收集函数在请求完成或失败时会立即移除error和close监听器。ECONNRESET;修复后测试通过。没有当时完整的请求日志,因此不能断言具体目标网址、工具调用或断线方。测试验证的是收集函数的事件生命周期缺陷,不是完整代理 CONNECT 端到端复现,也不能据此认定代理软件有故障。
根因与修复理由
TLS 握手未完成时连接结束,可能先触发
end,再触发 TLSerror。原代码在end中解析不完整响应失败后调用cleanup(),删除了错误监听器;后续错误因此成为未处理事件并终止 Node 进程。Promise 已经 reject 并不能自动处理 EventEmitter 后续的错误。data和end监听器,保留错误和关闭监听。once("error")改为on("error"),覆盖关闭前可能出现的后续错误。close中移除错误监听器,避免生命周期结束后仍保留该监听。settled保护,保持 Promise 只结算一次,后续事件不会覆盖原结果。本变更不添加全局 uncaughtException 处理,不禁用 TLS 证书校验,也不改变代理选择、重试或网络策略。
Validation
node --test tests/unit/web-proxy-tls.test.ts tests/unit/tools.test.ts:106 passed,0 failed。npm run check:types:0 diagnostics。npm run check:syntax:349 个文件通过。npm run check:dependencies:15 个外部依赖检查通过。git diff --check:通过。修复前新增回归用例出现未处理 TLS ECONNRESET;修复后通过。
未运行完整测试套件和浏览器测试,以上为本次相关检查。
I ran the repository's documented local checks (focused checks listed above).
I did not add credentials, private data, runtime output, or model artifacts.
I reviewed the changed-file list.
I will wait for every required CI check before merging.
I did not create or move a release tag in this pull request.