Repository navigation
test(cli): 放大 shell 回收用例启动预算,修 bun-test 正对照竞态 - #2596
Merged
Merged
Conversation
「retires rc background children after complete/timeout with a positive control」给 resolveCommandAsync 的 timeoutMs 只有 100ms。fixture 的 rc 一启动就后台拉起 sleep 并 echo $! 到 pidfile;在 bun-test 全量并发 (1823 个文件)的高负载 runner 上,新 fork 出的 /bin/sh 可能超过 100ms 才被调度,resolver 的定时器先到、SIGKILL 整个进程组,pidfile 里什么都没写——229 行正对照 pids().length > 0 拿到 0(run 41023870882 / job 123957266873,挡在 #2543 的 bun-test 首跑)。 两种模式(complete / timeout)共用同一条启动窗口,把两者的预算统一 放大到 2s: - complete 模式 rc 自身远在预算内退出,用例不因此变慢; - timeout 模式前景 sleep 5 仍确定性地走超时路径; - 2s 覆盖繁忙 runner 的进程启动(生产默认预算本就是 5s,100ms 只是 测试人为压紧)。 另把「立即读 pidfile」改成 2s 有界等待,吸收观测时序;真正关闭启动 竞态的是放大后的预算。 验证: - 本地给 fixture 注入 250ms 启动停顿精确复现 CI 报错(Expected > 0 / Received 0,两种模式各 1 次);同一停顿下修复后两模式全过。 - isolate-run 限 1 核 + 8 个满载空转 + 8 路并发 bun:修复版 24/24 全绿;完整文件 vitest 18/18、bun:test 18/18。 - 变异:删掉 registry.ts 里 finish() 的进程组 SIGKILL,257 行 toEqual([]) 两种模式各咬红 1 次,确认用例仍守着产品侧回收行为。 与 #2272 同族但不同窗口:#2272 是 complete 模式回收完成后的残留 (232 行),本次是 229 行正对照在 rc 被调度前就读取。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 30, 2026 09:37
复审指出上一提交只给 timeout 变体 2s 预算,complete 变体仍是 100ms, 同一启动竞态仍在。两变体共用同一套 rc(先后台拉 sleep 并 echo $!), 预算必须一致。 注入启动前延迟实测:150ms / 250ms 两档下,旧版 complete 变体各复现一次 Expected > 0 / Received 0(timeout 因已给 2s 通过);统一 2s 后两档 两个变体全部通过。无延迟时 vitest 18/18、bun:test 18/18。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
pushed a commit
that referenced
this pull request
Oct 30, 2026
This was referenced Oct 30, 2026
Owner
Author
|
复审中的一个非阻塞 P3(裸 |
This was referenced Oct 30, 2026
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 89a9cea…22d1c8d0b(20 个提交),同批合入的还有 #2546 #2556 #2589 #2591 #2545 #2538 #2595 #2597 #2581 #2539 #2598 #2515 #2536 #2575 #2366 #2606 #2544 #2593 #2603,失败不一定由本 PR 引起。
|
This was referenced Oct 30, 2026
|
🚀 Released in v3.56.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
test/resolve-command-shell-parse.test.ts的「async shell process-group retirement > retires rc background children after complete/timeout with a positive control」在 #2543 的 bun-test 首跑(run 41023870882 / job 123957266873)红在 timeout 变体 229 行:expect(pids().length).toBeGreaterThan(0)拿到 0。根因
用例给
resolveCommandAsync的timeoutMs只有 100ms。fixture 的 rc 启动后第一件事是后台拉起sleep 45并echo $!到 pidfile;但在 bun-test 全量并发(1823 个文件、多进程同时 fork)的高负载 runner 上,新 fork 出的/bin/sh可能超过 100ms 才被调度。resolver 的定时器先触发,对整个探测进程组发 SIGKILL(registry.ts的finish()),rc 从未执行到echo $!,pidfile 保持为空,正对照于是读到 0。complete与timeout两个变体共用这同一条启动窗口,这次只是 timeout 变体被撞上。与 #2272 同族但不同断言窗口(#2272 是回收完成后的残留读取,232 行;本次是 229 行正对照)。改了什么(仅测试,src 零改动)
sleep 5仍确定性走超时路径(inconclusive: true不变);验证
Expected: > 0 / Received: 0;同一停顿下修复后两变体全过。isolate-run --cpus 1(8 个满载空转 + 8 路并发 bun 测试进程)下修复版 24/24 全绿;完整文件 vitest 18/18、bun:test 18/18。src/adapters/cli/registry.ts里finish()的进程组 SIGKILL,257 行expect(running).toEqual([])在两个变体各咬红一次,确认改完的用例仍真实守着产品侧回收行为,不是被放松。🤖 Generated with Claude Code