@raolin2025/claude-code-node 2.6.4 → 2.6.5
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": "@raolin2025/claude-code-node",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications, Telegram & QQ Bot remote programming, rich media upload, multi-account management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/core/index.js",
|
|
@@ -273,6 +273,8 @@ export class TelegramListener {
|
|
|
273
273
|
this._pollTimer = null
|
|
274
274
|
this._retryDelay = 1000
|
|
275
275
|
this.maxRetryDelay = 30000
|
|
276
|
+
this._lastPollError = null // 最近一次轮询错误消息(用于去抖刷屏)
|
|
277
|
+
this._lastPollErrorAt = 0 // 最近一次轮询错误时间戳
|
|
276
278
|
this.conversations = new ConversationState()
|
|
277
279
|
this._onMessage = null
|
|
278
280
|
this._handlers = {}
|
|
@@ -323,6 +325,9 @@ export class TelegramListener {
|
|
|
323
325
|
const res = await this._fetch(url, {
|
|
324
326
|
method: 'POST',
|
|
325
327
|
headers: { 'Content-Type': 'application/json' },
|
|
328
|
+
// 长轮询本身最多等 30s(Telegram API 参数),HTTP 层超时必须更长,
|
|
329
|
+
// 否则代理路径(fetchViaSocks5)30s 硬超时会误杀长轮询 → HTTP request timeout 刷屏。
|
|
330
|
+
timeout: 60000,
|
|
326
331
|
body: JSON.stringify({
|
|
327
332
|
offset: this.lastUpdateId + 1,
|
|
328
333
|
timeout: 30,
|
|
@@ -360,7 +365,17 @@ export class TelegramListener {
|
|
|
360
365
|
this._retryDelay = 1000
|
|
361
366
|
|
|
362
367
|
} catch (e) {
|
|
363
|
-
|
|
368
|
+
// 错误去抖:连续相同的错误(如长轮询超时)只在首次/状态变化时打印,
|
|
369
|
+
// 避免 AI 处理长任务时 getUpdates 空转超时不断刷屏。
|
|
370
|
+
const msg = e.message || 'unknown'
|
|
371
|
+
const now = Date.now()
|
|
372
|
+
const isSame = msg === this._lastPollError
|
|
373
|
+
const isRecent = (now - (this._lastPollErrorAt || 0)) < 60000
|
|
374
|
+
if (!isSame || !isRecent) {
|
|
375
|
+
log(`[TG] Poll error: ${msg} (retry in ${this._retryDelay}ms)`)
|
|
376
|
+
this._lastPollError = msg
|
|
377
|
+
this._lastPollErrorAt = now
|
|
378
|
+
}
|
|
364
379
|
await this._sleep(this._retryDelay)
|
|
365
380
|
this._retryDelay = Math.min(this._retryDelay * 2, this.maxRetryDelay)
|
|
366
381
|
}
|
package/src/channel/tg-proxy.js
CHANGED
|
@@ -271,10 +271,13 @@ export async function fetchViaSocks5(url, options = {}, proxyAddr) {
|
|
|
271
271
|
|
|
272
272
|
return new Promise((resolve, reject) => {
|
|
273
273
|
let responseData = ''
|
|
274
|
+
// 超时可配置(options.timeout,毫秒),默认 30s。
|
|
275
|
+
// Telegram getUpdates 是长轮询(最多等 30s),必须传更大的超时避免误判超时。
|
|
276
|
+
const timeoutMs = options.timeout || 30000
|
|
274
277
|
const timeout = setTimeout(() => {
|
|
275
278
|
socket.destroy()
|
|
276
279
|
reject(new Error('HTTP request timeout'))
|
|
277
|
-
},
|
|
280
|
+
}, timeoutMs)
|
|
278
281
|
|
|
279
282
|
socket.write(reqBuf)
|
|
280
283
|
socket.on('data', (chunk) => {
|