Repository navigation
电脑代理 stdin 停机用例不再用 5 秒墙钟,改成和重连赛跑 (#79) - #88
Merged
Merged
Conversation
This was referenced Oct 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
joesmart
force-pushed
the
joesmart/fix-ci-flaky
branch
from
October 23, 2026 14:35
3b53b30 to
408349b
Compare
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.
改了什么
只改了一条测试:
packages/computer-agent/test/process.test.ts「stdin 关闭后代理自己停机」。原来写的是waitForExit(5_000),现在改成「进程退出」和「第二条重连日志」赛跑,断言退出先到,和旁边那条「控制面连不上时进程不退出」写法一样。产品代码没动。为什么
5 秒是从 spawn 算起的,不只算停机。在 CI 上加了临时探针,在 ubuntu-latest、Node 24 上跑了 39 轮,其中 36 轮压了 4 个 busy loop:
imports done(tsx 编译、加载 computer-agent → bot-runner → shared 整棵模块树):2.6–4.1s时间几乎全花在冷启动上,停机本身只占零头。
pnpm -r test是各包并行跑的,CPU 争抢比探针压得更重,启动就会超过 5s。失败的那次 run 里也能看到:同样要加载这棵模块树的 AGENT_TOKEN 用例要 2s 左右,这条超过 5014ms。赛跑能量的就是停机本身:代理要是没认 stdin 关闭,会一直去连
ws://127.0.0.1:1,第二条重连日志会先到。机器慢只会让两边一起变慢,不改变谁先到。本地压测复现了同一个红:每轮换一个新的
TMPDIR逼 tsx 冷编译,18 核上压 36 个 busy loop,旧写法 10 轮红 4 轮,报错就是等了 5000ms 进程还没退出,绿的几轮也要 4.5–4.9s;新写法 10 轮全绿,最慢一轮 6.3s。本地验证过它真能抓住坏掉的停机:把
main.ts里的process.stdin.once("end", stop)去掉,这条用例 1.5s 就红了(expected '输出' to be '退出 0')。还原后是绿的。另一条:bot-runner「截图进模型是图片……」没修
同一个 issue 里的 Chrome 截图用例,在 run 39767590315 和 PR run 39564987085 里失败过,都是
Page.captureScreenshot30 秒不回。探针在 CI 上照搬
ci.yml的 chromium、AppArmor、Xvfb 配置,跑了 48 轮(空闲 24 轮、加负载 24 轮),一次都没卡住:visible true 780x493captureScreenshot要 43–94ms最可能的根因是 headless Chromium 在 CI 满载时截图偶尔卡住,但没有复现,也没有证据,所以没有硬改代码或超时。这条拆到 #89 单独跟。
怎么验证的
另外两条 CI 不稳,根因不同,没在这里修
team-offer.test.ts「同群两张卡都确认成功……」:后台每 15 秒的审批超时扫描抢走了用例的mockImplementationOnce,本地确定性复现。记在 main 上 CI 不稳:computer-agent「stdin 关闭后代理自己停机」在 Linux 上间歇超时 #79 (comment)run-end.test.ts「删 Bot 已锁住它的 run 之后……」回 500:建 run 时撞runs_trigger_message_id_messages_id_fk,是删 Bot 和派活之间的真并发窗口,用例只跑了 440ms,不是慢。记在 main 上 CI 不稳:computer-agent「stdin 关闭后代理自己停机」在 Linux 上间歇超时 #79 (comment)临时探针提交(workflow 和三处 PROBE 代码)已从分支历史里拿掉,这里的 diff 只有这一条测试。
Refs #79(只修了「stdin 关闭后代理自己停机」,截图、team-offer、run-end 三条留在 #79 跟进)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni