Repository navigation
fix(cli): 代理回环直连、无法解析时不中断、空大写变量回退(0.9.2) - #31
Conversation
#30 的 Sourcery 审查指出的三处(0.9.1 已发出): - 本机回环地址始终加入 NO_PROXY:本地实例经代理不可达,明文 http 下 token 会经过代理 - 代理变量无法解析时提示并直连,不再让 build / bundle / schema 等离线命令失败 - `??` 改 `||`:HTTP_PROXY="" 不再遮住已配置的 http_proxy 每条各有测试;改回旧写法时对应测试失败。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideThis release hardens CLI proxy handling by forcing loopback requests to bypass proxies, tolerating invalid proxy settings through a stderr warning and direct fallback, and correctly honoring lowercase variables when uppercase values are empty; it also adds focused tests, documentation, and 0.9.2 version updates. Sequence diagram for resilient CLI proxy setupsequenceDiagram
participant CLI
participant Env
participant EnvHttpProxyAgent
participant Fetch
participant Updates
CLI->>Env: useEnvProxy()
Env-->>CLI: Read proxy variables
alt No usable proxy
CLI-->>Fetch: Use direct connection
else Proxy configured
CLI->>EnvHttpProxyAgent: Create with noProxy including localhost, 127.0.0.1, [::1]
alt Proxy settings valid
EnvHttpProxyAgent-->>CLI: Agent configured
CLI->>Fetch: Install global dispatcher
Fetch->>Updates: Request
else Proxy settings invalid
EnvHttpProxyAgent-->>CLI: Throw error
CLI->>CLI: Write warning to stderr
CLI-->>Fetch: Use direct connection
end
end
Flow diagram for CLI proxy environment fallbackflowchart TD
A[Read HTTP_PROXY and HTTPS_PROXY] --> B{Uppercase value is empty?}
B -->|Yes| C[Use lowercase variable]
B -->|No| D[Use uppercase variable]
C --> E{Usable proxy configured?}
D --> E
E -->|No| F[Direct connection]
E -->|Yes| G[Add loopback hosts to noProxy]
G --> H{EnvHttpProxyAgent accepts settings?}
H -->|Yes| I[Use proxy except loopback]
H -->|No| J[Warn on stderr]
J --> F
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
CodeSeer 审查
结论:批准(附 1 条建议)
摘要
本次改动为 CLI 代理配置增加了回环地址直连、无效代理配置降级直连以及大小写环境变量的空串回退,并同步将各包及生成字节码版本更新到 0.9.2。代理初始化失败时的常规单次 CLI 执行可以正常返回,但重复调用 useEnvProxy 时会保留之前的全局代理 dispatcher,和“直连”的降级语义不一致。
整个 PR 至 c5f5099 · gpt-5.6-terra
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the proxy selection or loopback exclusion is wrong, requests carrying update-service bearer tokens could be sent through an unintended proxy or fail to reach a local service, exposing credentials or causing an already-completed request to be misrouted. Reverting restores the prior proxy behavior, but any credentials exposed during the faulty interval cannot be recovered.
CodeSeer 审查 #31:先装过有效代理、再遇到无法解析的设置时,旧代理仍在生效。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
处理 #30 合入后才看到的 Sourcery 审查(三条都有效,0.9.1 已发出,本 PR 发 0.9.2):
NO_PROXY没列回环时,指向本地实例的请求也走代理:连不上本地服务,明文 http 下 bearer token 经过代理localhost、127.0.0.1、[::1](undici NO_PROXY 匹配用带方括号的 IPv6 写法)始终并入noProxy,与requireSecureUrl允许明文的回环集合一致keeps loopback direct even when NO_PROXY does not list itEnvHttpProxyAgent抛错,build/bundle/schema等离线命令也失败skips a proxy setting it cannot use…;另实测:在装好依赖的页面工程里HTTPS_PROXY="not a url" tinyui build只打一行提示,照常产出两页.jsbHTTP_PROXY=""时??取到空串,遮住已配置的http_proxy??改 `反向验证:把三处改回 0.9.1 写法,对应三条测试失败。
本地按 CI 顺序 build / schema:check / runtime:check / typecheck / test 全过(core 43、native 12、cli 96);挂代理端到端
tinyui pull成功。🤖 Generated with Claude Code
Summary by Sourcery
Make CLI proxy handling safer and more resilient for local and offline workflows.
Bug Fixes:
Documentation:
Tests:
Chores: