dsh-http-proxy writes bracketed IPv6 [::1] into child process env, crashing httpx-based MCP servers #6655
FiretrUCK666
started this conversation in
General
Replies: 1 comment
|
在 master(c291e7961)逐行确认了你报告的机制,结论:属实,且你的方案 3 是最稳的修法。
修复建议(= 你的方案 3):把 env 写入用的列表与 undici 那份拆开—— |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
DSH 报告稿:
[::1]写进子进程环境,导致 Python/httpx 客户端启动即崩摘要
@deepseek-ai/dsh-http-proxy会把含方括号的 IPv6 字面量[::1]合并进代理绕行列表,并通过
applyPolicyEnv()写回process.env的no_proxy/NO_PROXY。于是 DSH 启动的所有子进程都继承
NO_PROXY=localhost,127.0.0.1,::1,[::1],任何用 httpx(0.28.1)解析该变量的 Python 程序在构造默认 client 时直接抛异常退出:
受影响场景:basic-memory(MCP server,stdio 启动)、FastEmbed 语义嵌入、Hugging Face
snapshot_download等。表现为「子进程静默退出、工具不加载」,排查成本极高。定位(dsh 0.1.5-rc.1)
文件:
node_modules/@deepseek-ai/dsh-http-proxy/lib/index.js调用链:
withLoopback()(149-153 行)把该数组并入策略的noProxy;applyPolicyEnv()(334-347 行)→writeProxyEnv()(364-375 行)把no_proxy/NO_PROXY两个名字都写入process.env;为什么
[::1]现在可以去掉它被加进来的理由是 12-18 行注释里那句:「undici 会把裸
::1读成 host:port1,所以必须同时列
[::1]」。该理由对未安装的 undici 已经不成立。 本机 undici 8.10.2 的
lib/dispatcher/env-http-proxy-agent.js明确处理裸 IPv6:#parseNoProxy():「An IPv6 entry with a port must be bracketed:[::1]:443.A bare IPv6 address like
::1contains colons that must not be confused with ahost:port separator, so we handle it separately.」
#getProxyAgentForUrl():去掉端口后缀,并把[::1]归一成::1再比对。实测(无网络请求,只判路由,undici 8.10.2 + Node 24.14.0),目标
http://[::1]:7078:即:去掉
[::1]不影响 DSH 自身环回流量绕过代理的设计目标。复现
建议改动
"[::1]"(保留localhost、127.0.0.1、::1);[::1]是为旧版 undici 加的兼容项,且会破坏不认括号字面量的 HTTP 客户端(httpx、requests/urllib3 生态里部分实现同理);
不要写进
process.env(子进程是共用的)。建议的替代方案(若上游不愿改常量)
至少不要在
process.env上留下括号项——例如:::1;影响面
(Windows 11 / Python 3.12 / httpx 0.28.1 实测)。
Invalid port,很容易被误判为模型或网络问题。本机环境(供参考):Windows 11 10.0.26200;Node v24.14.0;dsh 0.1.5-rc.1;
undici 8.10.2;httpx 0.28.1(basic-memory 0.23.2 内置)。
All reactions