fix: claude遇到5xx错误不再停止调度

This commit is contained in:
shaw
2025-09-24 14:37:33 +08:00
parent f56d1edce0
commit 8b8e9703a1

View File

@@ -1615,7 +1615,7 @@ class ClaudeRelayService {
} }
// 🛠️ 统一的错误处理方法 // 🛠️ 统一的错误处理方法
async _handleServerError(accountId, statusCode, sessionHash = null, context = '') { async _handleServerError(accountId, statusCode, _sessionHash = null, context = '') {
try { try {
await claudeAccountService.recordServerError(accountId, statusCode) await claudeAccountService.recordServerError(accountId, statusCode)
const errorCount = await claudeAccountService.getServerErrorCount(accountId) const errorCount = await claudeAccountService.getServerErrorCount(accountId)
@@ -1631,10 +1631,10 @@ class ClaudeRelayService {
if (errorCount > threshold) { if (errorCount > threshold) {
const errorTypeLabel = isTimeout ? 'timeout' : '5xx' const errorTypeLabel = isTimeout ? 'timeout' : '5xx'
// ⚠️ 只记录5xx/504告警不再自动停止调度避免上游抖动导致误停
logger.error( logger.error(
`${prefix}Account ${accountId} exceeded ${errorTypeLabel} error threshold (${errorCount} errors), marking as temp_error` `${prefix}Account ${accountId} exceeded ${errorTypeLabel} error threshold (${errorCount} errors), please investigate upstream stability`
) )
await claudeAccountService.markAccountTempError(accountId, sessionHash)
} }
} catch (handlingError) { } catch (handlingError) {
logger.error(`❌ Failed to handle ${context} server error:`, handlingError) logger.error(`❌ Failed to handle ${context} server error:`, handlingError)