@simonyea/holysheep-cli 1.7.112 → 1.7.113

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.112",
3
+ "version": "1.7.113",
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",
@@ -181,6 +181,7 @@ function createConnectTunnel(proxyUrl, target, headers) {
181
181
  method: 'CONNECT',
182
182
  path: target,
183
183
  headers,
184
+ timeout: 15000, // CONNECT 握手 15 秒超时
184
185
  })
185
186
 
186
187
  request.once('connect', (response, socket, head) => {
@@ -191,20 +192,46 @@ function createConnectTunnel(proxyUrl, target, headers) {
191
192
  if (head?.length) socket.unshift(head)
192
193
  resolve(socket)
193
194
  })
195
+ request.once('timeout', () => {
196
+ request.destroy(new Error('CONNECT tunnel handshake timeout'))
197
+ })
194
198
  request.once('error', reject)
195
199
  request.end()
196
200
  })
197
201
  }
198
202
 
199
203
  function pipeWithCleanup(a, b) {
200
- // TCP keepalive 检测真正的网络断开(不用 stall timer,会误杀 extended thinking)
201
204
  for (const sock of [a, b]) {
202
205
  if (typeof sock.setKeepAlive === 'function') sock.setKeepAlive(true, 10000)
203
206
  }
204
207
 
208
+ // 单向响应超时:a 发了数据给 b,但 b 那边 30 秒没回任何数据 → 断开
209
+ // 解决 node proxy 进程挂了但 TCP 还 ESTABLISHED 的问题
210
+ // 不影响 extended thinking:thinking 时 a(客户端)没发新数据,不触发计时
211
+ let responseTimer = null
212
+ let bHasResponded = false
213
+ a.on('data', () => {
214
+ // 客户端发了数据(请求),开始等上游响应
215
+ if (!bHasResponded) {
216
+ if (responseTimer) clearTimeout(responseTimer)
217
+ responseTimer = setTimeout(() => {
218
+ if (!bHasResponded) {
219
+ a.destroy(new Error('upstream response timeout'))
220
+ b.destroy(new Error('upstream response timeout'))
221
+ }
222
+ }, 30000)
223
+ }
224
+ })
225
+ b.on('data', () => {
226
+ // 上游回数据了,清掉超时
227
+ bHasResponded = true
228
+ if (responseTimer) { clearTimeout(responseTimer); responseTimer = null }
229
+ })
230
+
205
231
  a.pipe(b)
206
232
  b.pipe(a)
207
233
  const close = () => {
234
+ if (responseTimer) clearTimeout(responseTimer)
208
235
  a.destroy()
209
236
  b.destroy()
210
237
  }