Skip to content

fix: web 存储降级横幅每 5 秒重复拉取诊断接口 → 按 topic 缓存 60s - #3108

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-14_diagnostics-fetch-cache
Oct 14, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-14_diagnostics-fetch-cache

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

这是啥问题

#3041 合入后,web 面板在存储降级时的轮询(5s)每次都重新拉取 /__bili/diagnostics:横幅每 5 秒重建一次 innerHTML 并重新执行 attachReportButtons,导致:

怎么修

验证

  • npx tsc --noEmit 0 错;tests/web-storage-banner.test.ts 4/4 绿(含新断言);
  • npm run build 通过。

review 来源:#3041 合并后 review(还发现两个可接受的小项:cooldown 场景横幅文案偏重、诊断 blob 含 12 行日志尾巴属用户主动上报,均不修)。

The web overview poll re-renders banners every 5s while storage is
degraded, and each re-render re-invoked attachReportButtons → a fresh
GET /__bili/diagnostics every 5s. Each hit rebuilds the full blob
server-side (listSessions + whole-file bili.log/bili.log.old reads), and
a failing endpoint re-toasted on every poll (the #1937 poll backoff does
not cover this fetch).

- cache the report per topic for 60s; cached hits bind without network
- toast once per topic on failure instead of every poll
- pin both behaviors with string assertions in the #3040 banner test
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-14_diagnostics-fetch-cache (dcdca55)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3555-pr.3108.87c695b

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3108.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

现在修复后还会每次拿全量日志吗

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

不会每次都拿了。这个修法是客户端缓存:诊断报告按 topic 成功拉取后缓存 60s,期间横幅每 5 秒的重渲染直接走缓存绑定按钮,不发网络请求——服务端也就不会重建诊断 blob(不做 listSessions、不做 bili.log / bili.log.old 的全文件读取)。开着面板时,全量日志最多每分钟读一次(原来每 5 秒一次,降 12 倍)。

两个边界说明:

  1. 单次请求本身仍是全量读两个日志文件——这次修的是频率,不是单次成本(服务端逻辑没动);
  2. 缓存在页面内存里,刷新即重置;多开标签页时每个标签各有一份缓存,各自最多 60s 触发一次全量拉取。

完整 review 结论随后补上(CI 有四个 test lane 红了,正在核实是否与本 PR 相关)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

结论先行:代码审核通过,可合;CI 的 4 个红灯与本 PR 无关——master 自 #3094 起就红在这 4 个 golden 测试上。已立项 #3121 + 修复 PR #3122,合并后本 PR rebase master 即转绿。

结构化八问

  1. 是什么问题:feat: web warning + generic diagnostics reporting when SQLite degrades to legacy-only (#3040) #3041 合入后,web 面板在存储降级时横幅每 5 秒轮询都重建 innerHTML 并重新执行 attachReportButtons,导致每 5 秒多发一次 /__bili/diagnostics 请求;服务端每次全量重建诊断 blob(listSessions() + 两个日志文件整体 readFileSync 再过滤);接口失败时错误 toast 也每 5 秒弹一次(管理页面全量加载历史会话时触发堆 OOM:需要有界分页、摘要统计与详情懒加载 #1937 退避只覆盖 overview 主请求)。
  2. 什么原因导致的:attachReportButtons 没有缓存层,renderBanners 每次调用都直接 fetch;服务端 diagnostics handler 按「每请求重建 blob」实现。频率问题在客户端(每次都取),单次成本(几 MB 日志读一次)本身可接受——修频率即可,不需要动服务端。
  3. 影响范围与严重程度:仅影响降级期间开着 web 面板的用户——每 5 秒几 MB 磁盘 IO、失败时 toast 刷屏;纯性能/体验缺陷,无数据丢失,不影响不开面板的使用。
  4. 怎么修复的:客户端按 topic 缓存诊断报告 60s(命中→直接绑定按钮,零网络请求)+ 失败 toast 每 topic 只弹一次;在既有 banner 测试里用字符串断言钉住两个行为。缓存在页面内存,刷新重置,多标签页各一份;60s 陈旧对「给用户一键建 issue」的数据完全够用。
  5. 是否有回归问题:逐项清点过——横幅显隐逻辑不变;复制/上报按钮行为不变(bindReport 提取保持原语义);overview 轮询与退避不变;服务端 diagnostics 契约不变(本 PR 零服务端改动)。两处有意行为变更(PR 正文已披露):① 诊断数据新鲜度「每次轮询」→「≤60s 陈旧/每 topic」;② 失败 toast「每次失败」→「每 topic 每页面加载一次」。无意外回归。CI 红灯不是本 PR 引入(见下节)。
  6. 是否破坏缓存:本改动就是新增一个客户端缓存;服务端缓存/重试/增量游标/去重键均未触碰。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。DIAG_CACHE_MS = 60_000 是客户端内部常量,不进配置面。

CI 红专项(与本 PR 无关,已独立处置)

顺带回答 @Dog 的问题

修复后不会每次拿全量日志了:开着面板时每 topic 最多每分钟触发一次服务端 blob 重建(含两次全文件读),原来每 5 秒一次,降 12 倍。边界:单次请求仍是全量读两个日志文件(修的是频率不是单次成本);缓存在页面内存里,刷新重置,多标签页各一份。

收工判定:代码通过审核,#3122 合并 + 本分支 rebase master 后即可转绿合并;合并操作留给你。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

更正(重要):上一条回复里「已立项 #3121 + 修复 PR #3122」是重复立项,现已收回。对账时发现:#3104 的并行审核在 03:06Z(比我早约 40 分钟)已就同一问题立项 #3113,修复 PR #3119 在途。我的检索查重没命中 #3113,漏检在此说明。

之前的八问结论维持有效:代码审核通过、本 PR 零回归、两处有意行为变更已披露。收工判定:代码可合;#3119 落地 + 本分支 rebase master 后 CI 转绿;合并留给你。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

笔误更正:上一条里「打 重复 标签」应为「打 duplicate 标签」(仓库现有标签名即英文 duplicate),其余表述不变。

@ranxianglei
ranxianglei merged commit b5b73b3 into master Oct 14, 2026
31 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.401-master.b5b73b3 (rolling master tag).

npm install -g billion-context@0.0.401-master.b5b73b3  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

@ranxianglei
ranxianglei deleted the 2026-10-14_diagnostics-fetch-cache branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant