mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 请求/v1/messages/count_tokens 的CanceledError 不再被记录为ERROR 日志
This commit is contained in:
@@ -1085,6 +1085,18 @@ router.post('/v1/messages/count_tokens', authenticateApiKey, async (req, res) =>
|
||||
return res.status(error.httpStatus).json(error.errorPayload)
|
||||
}
|
||||
|
||||
// 客户端断开连接不是错误,使用 INFO 级别
|
||||
if (error.message === 'Client disconnected') {
|
||||
logger.info('🔌 Client disconnected during token count request')
|
||||
if (!res.headersSent) {
|
||||
return res.status(499).end() // 499 Client Closed Request
|
||||
}
|
||||
if (!res.destroyed && !res.finished) {
|
||||
res.end()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.error('❌ Token count error:', error)
|
||||
if (!res.headersSent) {
|
||||
return res.status(500).json({
|
||||
|
||||
Reference in New Issue
Block a user