Fix #73: 持续性网络错误应计入熔断器 #74
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #73
问题描述
当前系统在遇到网络错误(如 DNS 解析失败、连接拒绝、超时等)时,不会触发熔断器保护,导致在供应商不可达时会一直重试,浪费时间和资源。
用户反馈的典型场景:
根本原因
errors.ts:189-212中的categorizeError()将所有非 HTTP 错误归类为SYSTEM_ERRORforwarder.ts:140-182中系统错误不会调用recordFailure(),不计入熔断器解决方案
1. 扩展错误分类 (
errors.ts)新增两种错误类型:
NETWORK_ERROR (持续性网络故障):
ENOTFOUND- DNS 解析失败ECONNREFUSED- 连接被拒绝(端口未监听或防火墙阻止)ETIMEDOUT- 连接或读取超时EHOSTUNREACH- 主机不可达(路由失败)ENETUNREACH- 网络不可达(网络层故障)TRANSIENT_ERROR (临时系统错误):
ECONNRESET(连接重置,可能是临时抖动)2. 优化重试策略 (
forwarder.ts)3. 改进日志和决策链
errorCode、willRecordFailure等诊断信息network字段记录网络错误详情(区别于provider和system)核心代码变更
errors.ts
forwarder.ts
预期效果
测试验证
建议测试场景:
持续性网络故障测试:
临时网络抖动测试:
供应商 HTTP 错误测试:
Checklist
errors.ts)forwarder.ts)close #73关键字dev分支🤖 Generated with Claude Code