Skip to content

test: guard log-mask #255 dead-upstream ports with holder+assertPortDead (#2889) - #2890

Merged
ranxianglei merged 3 commits into
ranxianglei:masterfrom
YunzhouLi-hub:2026-10-12_log-mask-dead-port
Oct 12, 2026
Merged

ranxianglei merged 3 commits into
ranxianglei:masterfrom
YunzhouLi-hub:2026-10-12_log-mask-dead-port

Conversation

@YunzhouLi-hub

Copy link
Copy Markdown
Contributor

Closes #2889

什么问题

tests/log-mask.test.ts 的 proxy error log: connection failure to non-public upstream leaks nothing (#255) 用例(:386 起)把路由硬编码到 http://127.0.0.1:59999,依赖"该端口无人监听 → 连接拒绝 → 代理回 502"这一前提;websocket upgrade required 用例(:539 起)同样硬编码 59999。#2878 的 windows-24 腿实测:并行进程短暂占用 59999 → fetch 建连成功、对端回 403 → 断言假红(run 38218031665 / job 114707404422)。与 #1689(同用例拿到 200)同族,是 #2548 动态端口改造的漏网点(当时只改了 MITM 隧道用例)。

怎么修的

复用同文件 MITM 用例已确立、#2548 引入的 holder+assertPortDead 模式:

  • 两个用例启动前先用 http.createServer holder 监听随机端口,取 deadPort 后关闭 holder;
  • 路由键、fetch URL(模板串)、泄漏断言三处全部动态化到 deadPort;
  • 拨号用例在 fetch 前紧贴调用 await assertPortDead(deadPort)(拨号瞬间证明端口确死,占领者会把预期拒绝变成 403/200);
  • 426 用例仅注册路由不拨号,故只动态化、不加 assertPortDead。

文件内已无 59999 硬编码(grep 仅剩注释)。

回归

  • tests/log-mask.test.ts 19/19 pass;Windows 本地连跑 3 次全绿(共 4 绿);
  • 纯测试卫生改动,零产品代码变更;不涉及缓存/设计/新配置。

行为变更

无产品行为变更。测试可观测差异:两用例的上游死端口从固定 59999 变为每次运行随机分配,泄漏断言随端口动态化。

@ranxianglei

Copy link
Copy Markdown
Owner

依然红

…2816)

tests/issue2752-forward-partial-outcome.test.ts (added by c81be81, merged via ranxianglei#2782) spawns the real MCP shim over stdio but was never registered in the ranxianglei#2816 tripwire, so every test job died at startup before running a single test since 467b0f6. Concurrency review for c=4: all HTTP servers bind listen(0) dynamic ports; the spawned shim is killed in afterEach; BILI_MCP_PROXY/BILI_CONVERSATION_ID are passed in the child env at spawn time; src/mcp.ts itself binds no port and writes no state. Registered after review per the tripwire contract.
@YunzhouLi-hub

Copy link
Copy Markdown
Contributor Author

windows-22 这次失败是已知 flake #2799 残留(golden-chat 临时目录 EPERM rmSync,同签名已在 #2878 详细分析;其修复 #2808 关闭未合入,在它落地前 windows 腿会随机假红)。本轮改动只动 tests/log-mask.test.ts,与本用例无交集。麻烦有 admin 权限的维护者 rerun,或随 #2898 合入后的刷新自动重跑。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

红已转绿。结论先行:这个 PR 的红不是你的改动造成的——是 master 侧 CI 基础设施自 467b0f648(#2782 合入)起就断了,四个 test leg 全部在启动时死亡,你的 log-mask 用例一行都没跑过。我已在你的分支上补了一个独立标注 commit 修好它。

按八问:

  1. 是什么问题:PR 的四个 test job(ubuntu 22/24、windows 22/24)全红,但死因与 PR 内容零交集。
  2. 什么原因导致的:两层。
  3. 影响范围与严重程度:master 侧 CI 基建缺陷——自 467b0f648 起任意 PR 的 test leg 整体假红(产品代码根本不执行);无产品影响。flake 部分:任意 PR 的 windows leg 低概率假红 + 重跑成本,已单独立项 #2908(含机制分析:driveWire finally 疑似未关最终 SessionStore 的 index.db 句柄 + tmp-rm 退避阻塞事件循环)。
  4. 怎么修复的:按 诊断为什么个别ci要跑10分钟以上,是否可以优化 #2816 tripwire 契约先做并发审查再登记——该套件全部动态端口(listen(0)、无固定端口)、每用例 spawn+kill、BILI_MCP_PROXY 走子进程 env、src/mcp.ts 自身无端口绑定/全局副作用,c=4 下安全。然后作为独立标注 commit 推到你的分支:fix(ci): register issue2752 spawner suite in LIVE_FILES (#2816)(2b7f7ec35,仅 scripts/run-ci-tests.mjs +1 行,按字母序插入)。本 PR 合并即同时治好 master。
  5. 是否回归:无。只动 CI 调度脚本的登记表一行,不改任何测试内容/断言/env;本地复放 gate 扫描通过;四 leg 全套件(6492 tests)通过。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:无。
  8. 是否引入新配置:无。

你原本的改动状态:log-mask 的动态 dead-port(holder + assertPortDead)在四个 leg 上全部通过——含 Windows,说明 #2889 的修法跨平台成立,无需再动。

CI 现态:2b7f7ec35 共 18 个 check run 全绿(test ×4、static-gates ×4、各 guard/docs/lock/build 等 ×10)。可以合并——合并动作留给你:#2890

@ranxianglei
ranxianglei merged commit 66e5658 into ranxianglei:master Oct 12, 2026
34 of 35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.320-master.66e5658 (rolling master tag).

npm install -g billion-context@0.0.320-master.66e5658  # 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.

YunzhouLi-hub pushed a commit to YunzhouLi-hub/billion-context that referenced this pull request Oct 12, 2026
… load (ranxianglei#2908)

ranxianglei#2816's c=4 concurrent test scheduling raised per-runner load so a transient Windows AV/indexer lock on sessions/index.db can outlast the old ~3.2s rmrf window (win-latest leg of PR ranxianglei#2890: EBUSY unlink index.db). A probe confirmed the golden harness holds no self-handle at rmrf time (flushAllSessions closes the store's shadow first), so this re-sizes the external-lock budget rather than masking an in-process leak. Ladder 25..1600ms (~3.2s/8 attempts) -> 25..3200ms (~7.6s/10 attempts); only paid when a race actually happens.
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.

flaky CI: log-mask #255 错误日志用例仍硬编码 59999 无守卫(#1689/#2548 残留),并行占用拿到 403 假红

2 participants