Skip to content

[Bug] UPSTREAM_STREAM_TIMEOUT_MS=300000 导致上游502时每次等待5分钟才能切换账号,严重影响响应速度 #264

@fanyuexiao

Description

@fanyuexiao

版本

v0.3.4

影响范围

Desktop

环境信息

  • macOS (Apple Silicon)
  • Codex CLI + CodexManager 桌面端
  • 8 个 ChatGPT Plus 账号,ordered 路由策略
  • model: gpt-5.5,reasoning: medium
  • UPSTREAM_STREAM_TIMEOUT_MS: 300000(默认值,未修改)

复现步骤

  1. 配置 ordered 路由策略,sort 最低的账号(优先级最高)被 chatgpt.com 拒绝返回 502
  2. 发送任意 Codex 请求
  3. 等待约 300 秒
  4. CM 才记录 FAILED_REQUEST 并尝试下一个账号

预期结果

  1. CM 应区分两种超时:
    • First-byte timeout(首字节超时):连接建立后若 N 秒内未收到第一个字节,立即判定失败(建议默认值 30s)
    • Stream idle timeoutUPSTREAM_STREAM_TIMEOUT_MS):正常 stream 传输过程中的空闲超时(300s 合理,用于长任务)
  2. 或者:增加 Circuit Breaker,对最近 N 次返回 502 的账号在一定时间内直接跳过,不等满 300s

实际结果

  • 每次上游 502 等待整整 300s 才切到下一账号
  • ordered 策略下,用户感知是"每个请求至少等 5 分钟"
  • chatgpt.com 服务不稳定期间,每天发生多次,极大影响工作效率

脱敏日志 / 截图

ts=1779527893 event=FAILED_REQUEST account_id=user-BRwSOiE59twTIOS9LQZf5xDg
upstream_url=https://chatgpt.com/backend-api/codex/responses
status=502 elapsed_ms=300006

ts=1779528604 event=FAILED_REQUEST account_id=user-1NXMXxShRof3PysMXGqC2VAB
upstream_url=https://chatgpt.com/backend-api/codex/responses
status=502 elapsed_ms=300009
Image

提交检查

  • 我已确认内容不包含敏感凭据
  • 我已阅读仓库的 SECURITY.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions