Repository navigation
fix(kernel): GitHub API 限流时改走网页通道下载内核 - #8
Merged
Merged
Conversation
未登录的 GitHub API 每小时只有 60 次额度,用尽后 kernel install 直接失败并只提示 「请求受限,请稍后再试」,用户没有任何补救手段。 - 请求受限(403/429)时改为解析公开网页:/releases 取标签(最多 3 页), /releases/expanded_assets/<tag> 取该版本的资源列表,形状与 API 一致后再走原有的 selectRelease 选择逻辑 - 网页请求单独使用 text/html Accept,否则 github.com 返回 406 - 支持 GH_TOKEN / GITHUB_TOKEN,认证后额度提升到 5000 次/小时 - 限流错误带上额度恢复时间,不再是一句「请稍后再试」 实测:API 返回 403 时,网页通道解析出 3 个可用版本,Windows x64 正确选中 chromium-v146.0.7680.177.5 / cloakbrowser-windows-x64.zip。
This was referenced Nov 1, 2026
这条测试从 PR #7 起在 windows-latest 上一直失败,但代码本身没问题: Windows 内核走 zip 分发,tar + .app 相对链接只服务 macOS。 - 保留 .app 相对链接的用例:加能力探测,本机建不出可穿越的目录符号链接时 带原因跳过(Windows 无开发者模式是 EPERM,有权限时 Node 也建出文件型链接)。 - 越界链接必须被拒的安全用例:改用直接写 tar 头构造成员,不再依赖 fs.symlinkSync —— 于是这条安全断言在每个平台都真跑,不再被跳过掩盖。
taisuii
force-pushed
the
fix/github-rate-limit-fallback
branch
from
November 1, 2026 15:15
6072474 to
aa8f84b
Compare
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.
问题
kernel install cloak 走的都是 �pi.github.com。该接口未认证时每小时只有 60 次额度,用尽后返回 403,代码只抛一句「请求受限,请稍后再试」,用户除了干等没有任何办法(实测当前 IP 的 X-RateLimit-Remaining 已经是 0)。
修复
1. 限流时自动改走公开网页通道(不消耗 API 额度)
解析结果保持 { tag_name, assets: [{ name, browser_download_url }] } 形状,直接复用原有的 selectRelease / matchAsset 逻辑,下载与签名校验流程完全不变。
2. 网页请求使用独立的 ext/html Accept
这一点是实测踩出来的:给 github.com 页面发 API 的 Accept: application/vnd.github+json 会直接返回 406。
3. 支持 GH_TOKEN / GITHUB_TOKEN
认证后额度从 60 次/小时提升到 5000 次/小时。
4. 错误信息带上额度恢复时间,不再是一句无用的「请稍后再试」。
实测(当前 API 仍处于限流状态)
`
API status = 403
网页通道取到的 Release 数 = 3
Windows x64 选中 = chromium-v146.0.7680.177.5 / cloakbrowser-windows-x64.zip
`
测试
pm test:34 通过,2 失败——失败的是 kernels-extract 里创建符号链接的 macOS 用例,Windows 未开开发者模式时 EPERM,改动前同样失败,与本次无关
说明
官方把不同平台的构建分散在多个 Release,最新几个版本只有 SHA256SUMS,所以网页通道需要逐页找;同时把每批 4 个版本的资源页并发拉取,命中 3 个可用版本即停止。