Skip to content

[PR] batch-C: storage/network/panel misc — 5 absorbed fixes + 1 new (#7407 DNS worker leak); #7419 investigated, no in-repo fix - #7449

Open
ranxianglei wants to merge 6 commits into
masterfrom
batch-C-2026-11-21
Open

ranxianglei wants to merge 6 commits into
masterfrom
batch-C-2026-11-21

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

这批是什么

一次小修批处理:把 5 个已评审通过的 PR 原样吸收进来(cherry-pick -x,保留原作者),外加 1 个新修(DNS 回退 worker 泄漏)。全部是单模块小修,每个都带回归测试。

吸收的原 PR

原 PR 原作者 内容
#6648 ranxianglei plugin-status 的 404 分支补上 CORS 头——DSH 面板跨端口轮询这个接口,404 没带 access-control-allow-origin 时浏览器直接报 "Failed to fetch",真实错误被网络错误盖住
#7349 Afloat16 CA 身份变化后,把旧的 direct/proxy 上游 dispatcher(连接池)全部退役——之前旧信任状态的 dispatcher 会一直留着
#7409 ranxianglei storage 启动日志行改成如实写出实际选中的模式和 writer 状态——#6480 默认翻转后,旧文案三个分句全错,把排查带向不存在的 dual-write
#7420 ranxianglei HEAD 响应不再触发 #821 的 null-body 告警——HEAD 本来就没有 body,这条告警对 HEAD 是误报
#7352 ranxianglei 钉住(pinned)会话的水位快路径 head 检查不再比较 message id——两边 id 来自不同命名空间永远不相等,pinned 会话每轮都 miss 回落 legacy

新修(本批自己写的)

#7407 — DNS 回退 worker 泄漏:隧道准入的 DNS 回退在一次性 worker 线程里跑,内层 2.5s 超时到点发 ETIMEDOUT 后,父进程只清外层定时器、从不 terminate 这个 worker——过期的 worker 连同它队列里还没跑完的 getaddrinfo(占着 libuv 池一个槽位)一直活着,反复失败的准入会攒下一串僵尸 worker。现在内层超时判词一到就 worker.terminate(),和外层超时同一套处理。回归测试用真实 Worker 实现 + 受控的卡死 lookup 边界:未修代码上失败、修好后通过,另有外层超时/正常成功两个对照。

#7419(pnpm allowlist)——查过了,本仓库没有可修的东西

dsh plugin add billion-context@latest 报 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED,被挡的包是 dshmarket@1.73.11——DSH 自己装进 profile 的 git 依赖(带 prepare 构建脚本),不是 billion-context 的依赖:本仓库 package.json / lockfile 里完全没有它,发布产物零 git 依赖。pnpm 的构建脚本白名单是项目级配置(装在哪就在哪的 pnpm-workspace.yaml allowBuilds),一个 registry 依赖自己 package.json 里的 pnpm 字段管不到别的项目——在本仓库加白名单条目是死配置。issue 里已有完整 triage(根因在 DSH profile + hub 归因),给了三步解阻方案和外部仓库修复计划。本 PR 不声称修 #7419,也不自动关它。

关联 issue

原 PR #6648 / #7349 / #7409 / #7420 / #7352 将在本批合并后由人工关单并注明"已收编进本批"。

测试

  • npm run typecheck 干净;5 个 cherry-pick 各自自带的回归测试 + 新写的 tests/tunnel-guard-worker-lifecycle.test.ts 全部在目标运行中通过(8 个目标测试文件 65/65)。
  • 全量套件以远端 CI test 车道为准(本地全量是环境噪音,不作合并依据,§7.2)。

ci-check and others added 6 commits November 21, 2026 15:13
… real error (#6642)

The 404 fallthrough in handlePluginStatus built headers by hand with only
content-type, while the 2xx branches above it use jsonHeaders() (which adds
access-control-allow-origin when a trusted origin is admitted). The dsh
Context tab polls this route cross-origin, so a bare 404 is rejected by the
browser as 'Failed to fetch', masking the real 'unknown plugin conversation'
error the panel is trying to surface.

Reuse jsonHeaders() in the 404 branch. Both 404 paths (fallback=latest
'since boot' and bare 'unknown plugin conversation') go through this one
writeHead, so one fix covers both. Negative case pinned: no trusted origin
→ no allow-origin header (never echoed to an untrusted caller).

(cherry picked from commit b154797)
… writer state (#7408)

The pre-#6480 wording ("storage.unified=full or BILI_STORAGE_UNIFIED=full:
... legacy files keep being written — unset the knob to roll back") survived
the pure-sqlite default flip. Under the default posture — no knob set, JSON
envelopes NOT written — all three clauses were false, contradicting the
accurate jsonWriter-off line persist.ts prints in the same boot and steering
field diagnosis into chasing a non-existent dual-write (#7408 §3b).

The line now branches on the raw selection (unifiedSelectionIsSqlite) and
the effective writer state (effectiveJsonWriterOff, which at that point
equals persist.ts's jsonWriterOff: mode is full, backend is sqlite, and an
encryption-blocked open never reaches the line):
  - writer off → "index.db is the load path AND the only persistent copy —
    JSON envelopes are not written; restore dual-write with
    storage.jsonWriter=on"
  - writer on + pure-sqlite selection → names the explicit
    storage.jsonWriter=on as the reason envelopes are written
  - writer on + explicit full → the historical dual-write wording, unchanged

maybeOpen/openAsync take the file-tier jsonWriter value as a new optional
parameter (persist.ts passes fileStorageJsonWriter() at both call sites);
the module doc header is updated to the four current postures.

Regression test: tests/issue7408-storage-boot-log.test.ts pins the exact
boot line for all five reachable postures.

Log wording only — no wire, config, or storage-semantics change.

(cherry picked from commit 3e82f42)
A HEAD response has no body by definition (RFC 9110 §9.3.2), so a 200
HEAD with a null body is normal, not the #821 anomaly. Health probes
(e.g. HEAD /api/hello) hit the relay's 2xx null-body branch on every
request and flooded bili.log with `[unknown] ← upstream 200 returned a
null body` lines — the exact noise in the #7072 report. The relay now
skips the warn for HEAD while still warning for a genuine 2xx null body
(204/304 on a body-bearing method).

No behavior change: the response is still relayed empty for HEAD (the
client gets the 200 with no body, as before); only the spurious warn is
suppressed.

(cherry picked from commit 83c0e04)
…ns (#7345)

The watermark fastpath head check compared a.id !== b.id between the fresh
head cores (content-hash ids minted by openaiToCore, h_…) and the stashed
seed cores. In a pinned session (pluginLaneServerHistory +
pluginMsgIdIncremental — the 2x2 traffic the fastpath exists to accelerate)
prepare-openai rebinds originalMessages to the POST-PIN cores before
finalizeWatermarkTurn, so the seed carries host/ledger msgids while a fresh
openaiToCore parse mints content-hash ids. The two id namespaces differ
structurally on every turn, so the comparison could never pass: every turn
of a pinned session logged fastpath miss (head-prefix-drift) and fell back
to the full legacy parse.

The id is not a content signal: exclude it from the head comparison (content
and role inequality are still caught, and a remint with identical bytes is
not a rewrite). Non-pinned traffic keeps content-hash ids on both sides, so
when a.id === b.id the full-JSON equality holds iff the id-stripped equality
holds — existing behavior is unchanged.

Regression test plays the field sequence: seed with a host-id list, then a
tail-only growth turn must HIT (was head-prefix-drift) and an in-place head
edit must still drift.

Fixes #7345

(cherry picked from commit ba4d5a6)
…r deadline settles the probe (#7407)

The tunnel-admission worker probe (the post-main-pool-exhaustion fallback
from #5222) runs in a throwaway worker thread with an inner 2.5s lookup
deadline and an outer 3s worker deadline. When the inner timer posted
ETIMEDOUT, the parent rejected the probe and cleared the outer timer but
never stopped the worker: the expired one-shot worker (and its still-
queued getaddrinfo, holding a libuv pool slot) stayed alive until
unrelated native work completed. Repeated failing admissions could each
retain a worker thread.

The message handler now requests worker.terminate() for the inner-deadline
ETIMEDOUT verdict — the same termination the outer deadline already used
— handling terminate's async rejection before the existing timeout error
is returned. Success and settled-failure verdicts are untouched (the
lookup has already completed there and the worker drains and exits on its
own). Admission classification, retries, and configured behavior are
preserved; no wire, config, or message-shape change.

Regression: tests/tunnel-guard-worker-lifecycle.test.ts runs the REAL
Worker implementation with a controlled stalled-lookup boundary (real
eval-worker plumbing; only dns.promises.lookup is replaced with a
never-settling boundary plus a liveness anchor). It fails on the unfixed
base (expired worker still alive after the ETIMEDOUT verdict) and passes
with the fix (terminated, exit code 1). Controls: the outer deadline
still stops a worker that cannot send its inner verdict, and a
successful localhost lookup exits normally with its addresses.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: batch-C-2026-11-21 (904d4e0)

Latest build — install this exact version

npm install -g billion-context@0.0.11181-pr.7449.21ffadf

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

Recent builds (commit → version)

commit version build
904d4e0 billion-context@0.0.11181-pr.7449.21ffadf build

Download artifact

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

Install instructions are refreshed on each push.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment