Skip to content

test(responses-ws): await side-request log line instead of racing the flush - #2041

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-04_ws-title-log-flake
Oct 4, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-04_ws-title-log-flake

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #2040

Single-line flake fix, surfaced by PR #2034's CI: the windows-latest/Node 22 cell failed with not ok 3142 - Responses WS: a title-persona side request rides the lane transport instead of 502ing (assertion saw an empty log snapshot); re-run of the same commit was green and the other three matrix cells were green on first run.

The title-persona test is the last reader in tests/responses-websocket.test.ts still using a raw synchronous fs.readFileSync(f.logPath) immediately after turn completion — a race against the tee-logger's file flush on loaded runners. Every sibling log assertion polls through readLogUntil() (introduced by 97ff781 for exactly this race class, #1968); this test postdates that sweep.

Change: one line — fs.readFileSync(f.logPath, "utf8") → await readLogUntil(f.logPath, [/side request \\(agent=title\\)/]). Both original assertions are kept unchanged and now vet the settled snapshot.

Verified locally: full tests/responses-websocket.test.ts 36/36 pass, typecheck clean. Full regression left to CI.

… flush (#2040)

The title-persona test was the last reader in this file still using a raw
synchronous fs.readFileSync right after turn completion. On loaded runners
the tee-logger write lags the wire completion, so the snapshot misses a
line that was logically already emitted — observed as a red
windows-latest/Node 22 cell in PR #2034's CI (run 37179443315), green on
re-run, green on the other three matrix cells.

Use the established readLogUntil() polling helper (added by 97ff781 for
exactly this race class, #1968). Both original assertions are unchanged
and now vet the settled snapshot.
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-04_ws-title-log-flake (b30e4e6)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2077-pr.2041.ea84b92

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-pr2041.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2041 review 结论 — 已核对代码与 CI,结论:可合并。

验证过程(非仅读 diff):取 PR 分支到本地,npm ci 后定向跑改动文件 tests/responses-websocket.test.ts → 36/36 pass;CI 全量 14/14 checks success,含此前挂掉的 windows-latest, 22 cell。diff 相对当前 master 恰好 1 文件 1 行,与描述一致。

结构化七问:

  1. 是什么问题:CI flake——title-persona WS 测试在 turn 完成后立刻同步读代理日志文件,撞上 tee-logger 的文件落盘延迟;windows-latest/Node 22 上负载高的 runner 里快照为空,断言失败;同 commit 重跑即绿(CI flake: responses-websocket title-persona test races the log-file flush (raw readFileSync) #2040)。
  2. 什么原因导致的:该测试晚于 readLogUntil 清扫(97ff781,feat: ACP-aware OpenCode V2 Responses WebSocket proxy + generic WS bridge shell (#1844/#1467) #1968 正是为这一类读竞争引入),是文件里最后一个裸 fs.readFileSync(f.logPath) 读者。已在 PR 分支核实:全文件其余 readFileSync 只剩 CA 证书加载(helper 内部轮询除外),"last reader" 说法成立。
  3. 怎么修复的:不再拍快照,改用既有轮询 helper 等目标行 side request \(agent=title\) 真正落盘(25ms 间隔、10s 有界超时、超时带 log tail 明确报错),两条原始断言原样保留,现在审的是已稳定的快照。修的是"读早了"这个机制本身,不是把症状糊掉。
  4. 是否有回归问题:审过的既有行为只有这一个测试自身。唯一语义差异:负断言 doesNotMatch(/Unsupported request.../) 现在看到的快照比原来略大(turn 完成到模式落盘之间多出的行)——但这些行只可能来自本测试自己的 fixture/服务进程窗口内,若真出现 502 类错误那是真信号而非噪音;不会引入新的假失败路径。最坏情况测试耗时 +10s,仍在既有 { timeout: 30000 } 内。生产代码零改动,wire/配置/持久化均不涉及。
  5. 是否破坏缓存:不涉及。
  6. 是否改了设计方向:不涉及——是把该测试对齐到既有 helper 纪律,方向收敛而非转向。
  7. 是否引入了新的配置:不涉及。

行为变更披露(测试时序):旧=turn 完成后立即一次性读日志;新=最多等 10s 直到目标行落盘再断言。仅限测试内部时序,不影响任何产品行为。

判定:diff 干净(1 行)、定向+全局 CI 全绿、修法与 #1968 确立的守卫一致——可合并。

@ranxianglei
ranxianglei merged commit af7718c into master Oct 4, 2026
14 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-04_ws-title-log-flake branch October 15, 2026 05:32
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.

CI flake: responses-websocket title-persona test races the log-file flush (raw readFileSync)

1 participant