feat(desktop): releaseNotes CDN 请求加重试逻辑 - #2507
Conversation
网络错误/超时自动重试(最多 3 次,指数退避 1s/2s/4s), HTTP 非 200 和 JSON 解析错误不重试(确定性失败)。 修复了海外用户从国内 CDN 拉取公告容易因瞬时丢包/超时 失败的问题。 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Lizi <jiali@magiclizi.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c86bae90ba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/releaseNotesService.ts | 新增结构化单次请求结果和指数退避重试,但缺少整体时间预算,使调用方最坏等待时间显著增长。 |
| apps/desktop/src/main/tests/releaseNotesService.test.ts | 覆盖了网络错误重试成功、404 不重试、重试耗尽和超时重试,但未覆盖上层串行调用的总等待时间。 |
Sequence Diagram
sequenceDiagram
participant UI as 公告入口
participant IPC as Electron IPC
participant Service as releaseNotesService
participant CDN
UI->>IPC: 获取 index / 版本公告
IPC->>Service: fetchCdnJson()
loop 首次请求 + 最多 3 次重试
Service->>CDN: net.request(15 秒超时)
CDN-->>Service: 网络错误或超时
Service->>Service: 退避 1s / 2s / 4s
end
Service-->>IPC: null
IPC-->>UI: 最晚约 67 秒后返回
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/main/releaseNotesService.ts:156-162
**重试缺少整体时间预算**
当 CDN 持续不可达或连续四次请求均超时时,单次调用会等待约 67 秒;自动公告流程还会串行获取 index 和版本公告,导致弹窗延迟约 134 秒,而手动公告入口也会超过一分钟没有响应。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(desktop): releaseNotes CDN 请求加重试逻辑" | Re-trigger Greptile
MagicLizi
left a comment
There was a problem hiding this comment.
已合并。releaseNotes CDN 重试逻辑干净利落——MAX_RETRIES=3 + 指数退避,404 不重试的分类也正确。测试覆盖了网络错误重试、超时重试、全部耗尽三种路径。🚀
这次改了什么
摘要
给 的 CDN 请求加自动重试:网络错误或超时时最多重试 3 次,指数退避 1s → 2s → 4s。HTTP 非 200(如 404)和 JSON 解析错误不重试(属于确定性失败,重试无意义)。
海外用户从国内 CDN 拉取公告容易因跨境网络抖动导致瞬时丢包/超时,目前一次失败即彻底放弃(auto 路径甚至是静默失败),加重试后大幅提升弱网环境下的成功率。
变更类型
feat新功能范围
releaseNotesService.ts:fetchCdnJson拆为单次尝试fetchCdnJsonOnce+ 带重试的fetchCdnJsonUI 变化
不涉及
怎么验证的
自动验证
手工验证
不涉及(逻辑变更仅影响 main 进程 CDN 请求行为,IPC 接口与 renderer 交互不变)
未执行的验证
无
风险
风险分类
影响与回滚
releaseNotesService的 CDN 请求路径(公告/更新通知拉取)提交前检查
git commit -s)🤖 Generated with Claude Code