@simonyea/holysheep-cli 1.7.66 → 1.7.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.66",
3
+ "version": "1.7.67",
4
4
  "description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
5
5
  "keywords": [
6
6
  "openai-china",
@@ -26,15 +26,20 @@ function maskKey(key) {
26
26
  return key.slice(0, 6) + '...' + key.slice(-4)
27
27
  }
28
28
 
29
- async function fetchWithRetry(url, opts = {}, retries = 3) {
29
+ async function fetchWithRetry(url, opts = {}, retries = 3, timeoutMs = 20000) {
30
30
  const fetch = require('node-fetch')
31
31
  for (let i = 0; i < retries; i++) {
32
+ const controller = new AbortController()
33
+ const timer = setTimeout(() => controller.abort(), timeoutMs)
32
34
  try {
33
- return await fetch(url, { timeout: 10000, ...opts })
35
+ const res = await fetch(url, { ...opts, signal: controller.signal })
36
+ clearTimeout(timer)
37
+ return res
34
38
  } catch (e) {
35
- // DNS 暂时失败 (EAI_AGAIN) 或网络抖动,重试
36
- if (i < retries - 1 && (e.code === 'EAI_AGAIN' || e.code === 'ETIMEDOUT' || e.code === 'ECONNRESET' || e.type === 'system')) {
37
- await new Promise(r => setTimeout(r, 1500 * (i + 1)))
39
+ clearTimeout(timer)
40
+ const retryable = e.code === 'EAI_AGAIN' || e.code === 'ETIMEDOUT' || e.code === 'ECONNRESET' || e.code === 'ECONNREFUSED' || e.type === 'system' || e.name === 'AbortError'
41
+ if (i < retries - 1 && retryable) {
42
+ await new Promise(r => setTimeout(r, 2000 * (i + 1)))
38
43
  continue
39
44
  }
40
45
  throw e