fix: 代理/VPN 网络错误时提示用户关闭代理重试#49
Conversation
|
Warning Review limit reached
More reviews will be available in 57 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds proxy network error detection to the API layer. When network requests fail, the code now checks if the error matches common proxy-related patterns and augments the error message with localized troubleshooting guidance. English and Chinese localization strings are included. ChangesProxy Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
当上传文件时遇到代理/VPN相关的网络错误(如 TLS 握手失败、 ECONNRESET 等),在错误信息中追加提示,引导用户关闭代理后重试。 覆盖的错误类型: - TLS 连接建立前 socket 断开 - ECONNRESET / ECONNREFUSED / ETIMEDOUT - 自签名证书相关错误 - EHOSTUNREACH / ENETUNREACH
7bd84e3 to
9aaa1ce
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/locales/en.ts`:
- Around line 185-187: Update the locale entry proxyNetworkErrorTips in
src/locales/en.ts to use a proper multiline/string template format that matches
Biome's expected formatting: replace the single-quoted string containing \n with
a template literal (backticks) and put each line on its own line (e.g. first
line "Common fixes:" then numbered lines) so Biome's multiline check passes;
ensure you keep the exact text and order and only change the quoting/formatting
around proxyNetworkErrorTips.
In `@src/locales/zh.ts`:
- Around line 171-173: The CI failure is due to Biome formatting of the new
Chinese locale entry proxyNetworkErrorTips; update the proxyNetworkErrorTips
value so it is a single-line string using escaped newlines (e.g. "\\n") instead
of any raw/multi-line breaks, ensure the surrounding quoting and trailing comma
match existing locale entries, and re-run format/lint to confirm Biome is
satisfied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 16370cd4-9d95-4fe8-b906-04cc0355bebf
📒 Files selected for processing (3)
src/api.tssrc/locales/en.tssrc/locales/zh.ts
| proxyNetworkError: | ||
| 'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.', | ||
| proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc', |
There was a problem hiding this comment.
Fix Biome formatting on the new locale entries (CI is currently failing).
Line 185-187 is reported by CI as not matching Biome’s expected multiline formatting for proxyNetworkErrorTips, so this PR will stay red until reformatted.
🧰 Tools
🪛 GitHub Actions: ci / 1_lint.txt
[error] 185-190: Biome formatting check failed. Formatter would have printed different content for proxyNetworkErrorTips key/value indentation/line breaks.
🪛 GitHub Actions: ci / lint
[error] 185-188: Biome formatter check failed. Formatter would have reformatted 'proxyNetworkErrorTips' to use a multiline structure.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/locales/en.ts` around lines 185 - 187, Update the locale entry
proxyNetworkErrorTips in src/locales/en.ts to use a proper multiline/string
template format that matches Biome's expected formatting: replace the
single-quoted string containing \n with a template literal (backticks) and put
each line on its own line (e.g. first line "Common fixes:" then numbered lines)
so Biome's multiline check passes; ensure you keep the exact text and order and
only change the quoting/formatting around proxyNetworkErrorTips.
背景
部分用户在使用代理/VPN 时上传热更包会遇到不常见的网络报错,例如:
当前错误信息没有给出任何解决建议,用户不知道如何处理。
改动
isProxyRelatedError检测函数,匹配常见代理/VPN 相关的网络错误模式uploadFile和query的 catch 块中,检测到代理相关错误时追加提示信息proxyNetworkError和proxyNetworkErrorTips翻译覆盖的错误模式
socket disconnected before secure TLS connection(用户遇到的)ECONNRESET/ECONNREFUSED/ETIMEDOUTDEPTH_ZERO_SELF_SIGNED_CERT/UNABLE_TO_VERIFY_LEAF_SIGNATURE/CERT_HAS_EXPIREDself signed certificate/proxyEHOSTUNREACH/ENETUNREACH效果
用户遇到此类错误时,会看到:
Summary by CodeRabbit