Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,45 @@ function createRequestError(
return requestError;
}

const PROXY_ERROR_PATTERNS = [
'socket disconnected before secure TLS connection',
'ECONNRESET',
'ECONNREFUSED',
'DEPTH_ZERO_SELF_SIGNED_CERT',
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
'CERT_HAS_EXPIRED',
'self signed certificate',
'proxy',
'ETIMEDOUT',
'EHOSTUNREACH',
'ENETUNREACH',
];

function isProxyRelatedError(error: unknown): boolean {
const msg =
error instanceof Error
? error.message
: typeof error === 'string'
? error
: '';
const lower = msg.toLowerCase();
return PROXY_ERROR_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
}

async function query(url: string, options: RuntimeRequestInit) {
const baseUrl = await getBaseUrl;
const fullUrl = `${baseUrl}${url}`;
let resp: RuntimeResponse;
try {
resp = await runtimeFetch(fullUrl, options);
} catch (error) {
throw createRequestError(error, fullUrl);
const baseError = createRequestError(error, fullUrl);
if (isProxyRelatedError(error)) {
throw new Error(
`${baseError.message}\n\n${t('proxyNetworkError')}\n${t('proxyNetworkErrorTips')}`,
);
}
throw baseError;
}
const text = await resp.text();
let json: any;
Expand Down Expand Up @@ -230,6 +261,13 @@ export async function uploadFile(fn: string, key?: string) {
body: form,
});
} catch (error) {
if (isProxyRelatedError(error)) {
const rawMessage =
error instanceof Error ? error.message : String(error);
throw new Error(
`${rawMessage}\n\n${t('proxyNetworkError')}\n${t('proxyNetworkErrorTips')}`,
);
}
throw createRequestError(error, realUrl);
}

Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
nodeHdiffpatchRequired:
'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
apkExtracted: 'APK extracted to {{output}}',
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',
Comment on lines +185 to +187
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.

};
3 changes: 3 additions & 0 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@ export default {
nodeHdiffpatchRequired:
'此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
apkExtracted: 'APK 已提取到 {{output}}',
proxyNetworkError:
'网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。',
proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};
Loading