Skip to content

fix: 代理/VPN 网络错误时提示用户关闭代理重试#49

Merged
sunnylqm merged 1 commit into
masterfrom
fix/proxy-network-error-hint
Jun 5, 2026
Merged

fix: 代理/VPN 网络错误时提示用户关闭代理重试#49
sunnylqm merged 1 commit into
masterfrom
fix/proxy-network-error-hint

Conversation

@sunnylqm
Copy link
Copy Markdown
Collaborator

@sunnylqm sunnylqm commented Jun 5, 2026

背景

部分用户在使用代理/VPN 时上传热更包会遇到不常见的网络报错,例如:

FetchError: request to https://pushy-bj.oss-cn-beijing.aliyuncs.com/ failed, reason: Client network socket disconnected before secure TLS connection was established

当前错误信息没有给出任何解决建议,用户不知道如何处理。

改动

  • 新增 isProxyRelatedError 检测函数,匹配常见代理/VPN 相关的网络错误模式
  • uploadFilequery 的 catch 块中,检测到代理相关错误时追加提示信息
  • 中英文 locale 新增 proxyNetworkErrorproxyNetworkErrorTips 翻译

覆盖的错误模式

  • socket disconnected before secure TLS connection (用户遇到的)
  • ECONNRESET / ECONNREFUSED / ETIMEDOUT
  • DEPTH_ZERO_SELF_SIGNED_CERT / UNABLE_TO_VERIFY_LEAF_SIGNATURE / CERT_HAS_EXPIRED
  • self signed certificate / proxy
  • EHOSTUNREACH / ENETUNREACH

效果

用户遇到此类错误时,会看到:

FetchError: ...
URL: https://pushy-bj.oss-cn-beijing.aliyuncs.com/...

网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。
常见解决方法:
1. 关闭系统代理或 VPN
2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量
3. 检查 .npmrc 中的 proxy 配置

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages and troubleshooting guidance for proxy and VPN-related network failures, with support for English and Chinese.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

Warning

Review limit reached

@sunnylqm, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf4ef59c-1aad-4189-bace-13fac78fb886

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd84e3 and 9aaa1ce.

📒 Files selected for processing (3)
  • src/api.ts
  • src/locales/en.ts
  • src/locales/zh.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

Proxy Error Handling

Layer / File(s) Summary
Proxy error detection and API handling
src/api.ts
PROXY_ERROR_PATTERNS set and isProxyRelatedError() helper detect proxy/TLS/network failures in error messages. query() and uploadFile() catch handlers classify errors and throw i18n-augmented messages with error description and tips when proxy-related, else fall back to standard error creation.
Localization strings for proxy errors
src/locales/en.ts, src/locales/zh.ts
English and Chinese i18n entries added: proxyNetworkError (error message) and proxyNetworkErrorTips (multiline troubleshooting steps for proxy settings, environment variables, and configuration).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A proxy problem caught with care,
Now error messages help debug with flair!
Chinese and English, side by side,
Network hiccups have nowhere to hide! 🌐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding proxy/VPN error detection and providing users with helpful troubleshooting suggestions when such errors occur.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/proxy-network-error-hint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

当上传文件时遇到代理/VPN相关的网络错误(如 TLS 握手失败、
ECONNRESET 等),在错误信息中追加提示,引导用户关闭代理后重试。

覆盖的错误类型:
- TLS 连接建立前 socket 断开
- ECONNRESET / ECONNREFUSED / ETIMEDOUT
- 自签名证书相关错误
- EHOSTUNREACH / ENETUNREACH
@sunnylqm sunnylqm force-pushed the fix/proxy-network-error-hint branch from 7bd84e3 to 9aaa1ce Compare June 5, 2026 08:55
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 78cc077 and 7bd84e3.

📒 Files selected for processing (3)
  • src/api.ts
  • src/locales/en.ts
  • src/locales/zh.ts

Comment thread src/locales/en.ts
Comment on lines +185 to +187
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',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Comment thread src/locales/zh.ts
@sunnylqm sunnylqm merged commit 8d413aa into master Jun 5, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant