fix(updater): use GitHub atom feed for Beta lookup, dodge API rate limit#350
Merged
Conversation
用户报「获取 Beta 版本信息失败」根因:fetch_latest_beta_release 调 api.github.com/repos/.../releases,未认证 60 req/h/IP。多次切 Beta toggle + 同 IP 共享配额(公司/家庭网络后),轻易撞 403 rate limit exceeded。 现场实测 IP 已耗尽:x-ratelimit-remaining: 0。 修法:换成 GitHub releases.atom(公开 RSS feed,CDN cache,无 API rate limit)。 具体改动: - fetch_latest_beta_release 端点从 api.github.com 改成 github.com/.../releases.atom - 提取一个纯函数 parse_latest_beta_from_atom 做字符串解析(不引 XML 库—— feed 格式稳定,找 /releases/tag/ 锚点抓 tag 即可),方便单测 - atom feed 不显式标 prerelease,但项目约定 tag 后缀 `-beta-tauri` 就是 Beta, 过滤后缀已足够 - timeout 从 10s 提到 15s,给跨境网络更多余地 - 加 2 个 unit test:(1) 混合 stable+beta 时返回 Beta entry;(2) 全 stable 时返回 None。两个 test 都已 pass 不改前端:JS 端调用签名 / 错误展示路径不变,下次 Beta-3 release 出来后用户 装上即生效。
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
User description
Root cause
用户在 Beta-2 build 上点「加入 Beta 渠道」开关时显示「获取 Beta 版本信息失败」。现场 curl 实测:
```
HTTP/2 403
x-ratelimit-limit: 60
x-ratelimit-remaining: 0
{"message":"API rate limit exceeded for 103.62.49.154. ..."}
```
`api.github.com` 未认证调用是 60 req/h/IP——我之前 debug 调用 + 用户切 toggle 几次,同 IP 池就被耗尽了。在公司/家庭共享出口下,多个用户的 OpenLess 实例共用同一额度,更容易撞。
Fix
换成 `https://github.com/appergb/openless/releases.atom\`(公开 RSS,CDN cache,无 API rate limit)。
Frontend not touched
JS 端 `invoke('fetch_latest_beta_release')` 签名 / 错误展示完全没动。Beta-3 build 装上后用户切 toggle 就直接生效。
Why atom over keeping API but adding auth
需要 GITHUB_TOKEN 注入到客户端——把任何 token 打进每个用户的 build 都不合理(公开二进制、token 要么暴露要么共享)。Atom feed 是无认证 + 无 rate limit 的天然解。
PR Type
Bug fix, Tests
Description
Replace API call with Atom feed to avoid rate limit
Increase timeout from 10s to 15s
Parse feed with string matching, no XML lib
Add tests for Beta tag detection
Diagram Walkthrough
File Walkthrough
commands.rs
Replace API with Atom feed for Beta release lookupopenless-all/app/src-tauri/src/commands.rs
limit
parse_latest_beta_from_atomandextract_betweenforlightweight XML parsing
returning none