Repository navigation
[PR] fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works - #5147
Conversation
…s its data (#5146) The DSH frame-level upstream banner (shipped via 6874e39 from #4254) polls /__bili/upstreams every 10s, but its server half never landed: PR #4257 closed unmerged and the re-land (050241c) kept only the egress fixes. Every poll therefore 404'd AND was CORS-blocked in the DSH renderer (admin JSON routes send no Access-Control-Allow-Origin), so the banner never showed and each session logged one console error per 10s. - Add loopback-gated GET /__bili/upstreams to handleAdminRoute projecting the alert table + open circuits into the #4254-settled contract {upstreams:[{host,port,kind,code,hint,count,firstSeen,lastSeen,circuit}]}; one row per host, the OPEN circuit outranks alerts (fail-fast stops minting alerts once open, so it is the authoritative down signal), alerts cover the pre-circuit window and carry the hint. - Echo the requesting Origin as ACAO on this route only — same gate-first pattern as the /__bili/ shell and /__bili/plugin/status (#3862); only origins the trusted-origin gate admitted reach dispatch, so the echo cannot widen the admin surface. No Origin (curl/probes) → no ACAO, unchanged. - Capture the errno at failure time into UpstreamAlert/UpstreamCircuitFailure (optional code field) so the report shows WHY beyond the classified kind — the client banner renders it when present. - Tests: projection semantics (alert-only window / circuit precedence / recovery drops the host / portless host) plus the HTTP surface (ACAO echo, healthy empty list without ACAO, non-loopback 403, tunnel 403).
… has no @deepseek-ai packages (#5146) Attached sub-problem of #5146: on DSH Desktop bundle installs the profile's node_modules holds third-party plugins (billion-context) alone — the @deepseek-ai core ships inside the app — so all three lookups missed and reports read 'dsh ?, dsh-compaction-basic ?, dsh-web-app ?', losing the host-version dimension with no hint where to look. When NONE of the three resolves for a profile, the line now says so explicitly (and asks reporters to include the app version); partial absence keeps the per-package '?'.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7259-pr.5147.f168366This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5147.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。open+closed 全量检索 upstreams / upstreamBanner / CORS / 横幅,无同症状同机制条目;相关历史为 #4254 → #4257 / #4267,两者均已关闭且未合并(#5146 是 DIGEST DRIFT,与本问题无关,编号巧合)。 标签: 开工计划(按 issue「一个闭环」四件落地,客户端零改动):
定向测试本地跑,全量回归交 CI。代码落地后即提 PR 并回贴链接。 |
The new GET /__bili/upstreams read contract (UpstreamHealthEntry / UpstreamHealthReport) is referenced only inside src/upstream-alerts.ts; admin.ts consumes getUpstreamHealthReport() structurally via JSON.stringify. Keep the exports so the wire shape stays named at its definition site, mirroring the LastInstallRecord / ResidentFieldBreakdown+MemoryReport precedents in the same WAIVERS list.
(ai: vllm-qwen/qwen3.8-27b) CI 已直接在 PR 分支上修好并推送, 红在哪:PR 新增的 怎么修的:在 八问:
push: |
(ai: vllm-qwen/qwen3.8-27b) 先说结论:这不是要我另开 PR 的任务。 查重命中在途 PR #5147(同症状、同机制、同方案),它已经完整实现了这个闭环。按「已有修复 PR 在途 → review/接力,不并列开重复 PR」的纪律,我没有新开 PR,而是:①独立从零复现了同一修复做本地验证;②拉取并审阅了 #5147 的实际代码与测试覆盖;③修掉它一处元数据缺陷。 我实际做的事(可复核):
八问
合并判定:修复已完成并落在 PR #5147,代码审核通过(我的独立复现证明其设计成立且可测)。CI 在其 head 上运行中——static-gates / mysql-contract / pi-subagents-guard / test-import-graph / docs-coverage 已 success/skipped,test shards 进行中,暂无失败;全量绿是合并前最后一道门禁。待 CI 转绿后即可由你合并(mergeable_state 现为 behind,master 已前进;如需要我可把 master rebase 进 #5147 让 CI 重跑)。 |
…ili-upstreams-endpoint
(ai: vllm-qwen/qwen3.8-27b) 这轮 7 个 test 分片红不是本 PR 的代码问题,是继承性 master 红。已按 CI 协调政策把 怎么判定的(拉了全部 7 个分片日志逐条核对,22 处 not-ok 全数清点):失败用例 100% 落在 master
做了什么:merge 八问:
push: |
…pdate-branch: sync past 6db5906)
…uires (#4599) The #5140 recovery test proves forkSnapshot reconstructs a non-retained parent's raw tail from the UNIFIED index — but it never pinned its own storage mode. Under the CI storage baseline (preload-storage-baseline.mjs sets BILI_STORAGE_UNIFIED=legacy for the broad corpus) no unified rows exist, so the reconstruction has no source and forkSnapshot fails closed with 409 SNAPSHOT_UNAVAILABLE. Deterministic, not a flake: reproduces 100% on master and any merged branch with BILI_STORAGE_UNIFIED=legacy, passes without it (default shadow). Pin full like the sibling persist tests and restore the ambient value afterwards.
…pdate-branch: sync past 44067a5)
ci-fixes at 67f8e89 still leaves four Windows shards red, and all four deltas already exist on PR #5178. This ports the missing hunks so the convergence branch actually converges. 1. `test (windows-latest, 2x, 3)` — #5103. `UnifiedShadow` builds its db path as `${dir}/index.db`, so the open-failure warning reads `C:\...\sessions/index.db`. `issue5103` asserts the warning contains `path.join(dir, "index.db")` — `...\index.db` on win32 — so a mixed separator never matches. `path` is already imported at :30 and the db is opened through the same join, so POSIX output is byte-identical. 2. `test (windows-latest, 22, 4)` + the 4788 leg — #4739/#4788 teardown. The suites arm a real `SessionStorage` under `BILI_STORAGE_UNIFIED=full`, so the sidecar is still open at teardown. `cancelAll()` clears timers and the build map but never closes the shadow; Windows refuses to unlink a directory holding an open file (`EBUSY`/`EPERM` on `index.db`). Use `closeQuietly()` — cancel, then close — in the short-lived-store teardown. 3. `test (ubuntu-latest, 24, 3)` + `(windows-latest, 22, 2)` — #5155. Both cold-rebuild cases waited for the debounced durable flush with a fixed `setTimeout(20)`. A millisecond budget is a deadline a loaded runner can miss, and the miss is an honest `409 !== 200` from a one-turn-stale table. Await the settle itself: `afterNextFlush("conv-ptrs")` resolves once the armed save lands. 4. `test (ubuntu-latest, 22, 3)` — #4788 verdict deadlock. `afterNextFlush` parks a resolver in `flushWaiters`, and the only thing that drains it is the debounce timer — which is armed `unref?.()`. Once that timer is the last pending handle the loop drains, the promise never settles, and node reports `Promise resolution is still pending but the event loop has already resolved`. Keep the timer referenced exactly while a waiter exists (`ref()` on waiter registration; the host-upkeep default stays unref'd). Both view hunks and the two test-teardown hunks are byte-identical to the ones already on PR #5178, so this converges the branches instead of inventing a third variant. Verified locally: `npx tsc --noEmit` clean; issue4788 0/4 -> 4/4; issue4739 4/4; issue5103 5/5; inc-canonical-pointers 3/3. The `cancelAll` -> `closeQuietly` hunk has no local negative control: reverting it keeps Linux green because `EBUSY`/`EPERM` only fire where an open handle blocks unlink. That control can only run on a Windows lane — stated rather than papered over. The #4788 arm's own reader is confirmed instead: `cancelAll()` leaves `index.db`, `index.db-shm`, `index.db-wal` in `/proc/self/fd` while `closeQuietly()` leaves none (probed directly).
…e settle (#4599) The turn() helper arms scheduleSave whose debounce timer is unref by design (persist.ts: a pending save must not hold the process open at shutdown) and then awaits afterNextFlush. Nothing else in that await is refd, so in a node:test child whose only surviving handles are unref sockets the event loop drains before the 50 ms debounce fires and the settle promise never resolves: all four subtests fail with "Promise resolution is still pending but the event loop has already resolved" / cancelledByParent. Reproduced deterministically on master 44067a5 AND on pre-merge ci-fixes 67f8e89 (standalone run, exact CI preload chain), while the same file has passed some CI legs by ambient-liveness luck - a born-flake per section 7.2 (no environmental luck). The pin at 67f8e89 does not touch this path. Fix: arm a refd 25 ms keep-alive interval around the afterNextFlush await (cleared in finally) so the debounce fires deterministically on every host. Test-only diff; production settle semantics untouched.
…ts ref-tracking fix (#4599) PR #5262 fixes #4788 at the source: scheduleSave now leaves the debounce timer refd while flush waiters exist (and afterNextFlush refs a pending unrefd timer when a waiter registers), so the settle is deterministic for EVERY caller on every host. The 25 ms keep-alive interval added in a3019b0 only patched this one test file and is redundant now; removing it leaves one mechanism instead of two. The comment stays: without it a future reader re-adds the interval or deletes the persist.ts tracking as dead weight.
…ili-upstreams-endpoint
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.966-master.1876186 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #5145
查重: 无(open+closed issue/PR 全量检索 upstreams / upstreamBanner / CORS / 横幅,无同症状同机制条目;相关历史为 #4254 → #4257/#4267,两者均关闭未合并——见下)。
What happened
The DSH frame-level upstream banner (shipped in 6874e39 from #4254) polls
GET /__bili/upstreamsevery 10 s. Its server half never landed: PR #4257 closed unmerged and the re-land 050241c kept only the egress fixes, so every poll 404s AND is CORS-blocked in the DSH renderer (admin JSON routes send noAccess-Control-Allow-Origin). Result: the banner slotbili-upstreamsnever shows, and each session logs one console error per 10 s (19+/day for the reporter).Fix (one closed loop)
GET /__bili/upstreamsinhandleAdminRouteprojecting the alert table + open circuits into the Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254-settled contract{upstreams:[{host,port,kind,code,hint,count,firstSeen,lastSeen,circuit:{state,nextProbeInMs}|null}]}: one row per host; an OPEN circuit outranks alerts (fail-fast stops minting alerts once open — it is the authoritative down signal); alerts cover the pre-circuit window and carry the hint./__bili/shell and/__bili/plugin/status([Bug] Inconsistent host-side context statistics after compression in dsh plugin mode (ref: dsh-context#173) | [Bug] dsh 插件模式压缩后宿主侧上下文统计不一致(引用 dsh-context#173) #3862): only origins the trusted-origin gate admitted reach dispatch, so echoing cannot widen the admin surface.codeonUpstreamAlert/UpstreamCircuitFailure) so the report shows WHY beyond the classified kind; the client banner renders it when present.No client-side change: once the request returns 200+ACAO the browser stops logging; proxy-down degrades to a plain network-error rejection (no CORS line), same behavior as the Context-tab poller.
Behavior changes (old → new)
GET /__bili/upstreams(additive; nothing changes until something polls it).access-control-allow-originequal to the requesting Origin when one is present — new route only; every other admin route's headers are byte-identical to before./__bili/overview'supstreamAlertsentries may now include an optionalcodefield (errno at failure time) — additive, ignored by existing consumers.Tests
New
tests/issue5146-upstreams-endpoint.test.ts(projection semantics: alert-only window / circuit precedence / recovery drops the host / portless host; HTTP surface: ACAO echo, healthy empty list without ACAO, non-loopback 403, tunnel 403) plus an extended fixture + assertion intests/web-diagnostics-enrichment.test.ts. Targeted suites green locally (70 tests across the eight files touching these modules); full-suite verdict comes from CI.