test(codex): 用例失败时也回收 fake app-server,防止孤儿进程 - #1582
Merged
Merged
Conversation
fake-codex-rpc-server 以 detached + unref 方式拉起,只有 engine.stop() 能杀掉它;而各用例都把 stop() 放在最后一行,断言先抛就执行不到, fixture 会在 vitest 退出后以孤儿进程形式长期存活并占着端口 (本机实测一个这样的残留跑了 57 天)。 makeEngine 登记每个 engine,afterEach 统一 stop()(stop 幂等)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xu4wang
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
September 25, 2026 18:58
Owner
|
你好 @xu4wang,感谢提交 PR!我们已为这个 PR 创建了飞书评审群,自动评审正在进行中。系统自动拉你入群时失败了,麻烦点击下面的一年有效链接自行加入评审群,后续评审意见和沟通都会在群里同步: 也可以在名单文档中核对/更新你的飞书信息:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe 本条为自动流程发出,最终评审结论以维护者审阅为准,谢谢! |
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/codex-rpc-engine.test.ts里的 fake app-server(test/fixtures/fake-codex-rpc-server.mjs)由CodexRpcEngine以detached: true+unref()拉起(src/codex-rpc-engine.ts),独立进程组,vitest 退出不会带走它,只有engine.stop()能回收。而各用例都把
engine.stop()写在最后一行(全文件仅 1 处用了finally、没有afterEach)——只要stop()之前有断言失败 / 抛错,fixture 就会以孤儿进程(ppid=1)长期存活并占着一个本地端口。实际机器上发现过一个这样的残留跑了 57 天。改动
仅测试文件:
makeEngine把每个 engine 登记到集合里,afterEach统一stop()后清空。stop()幂等(已有用例覆盖),用例里原有的engine.stop()保持不动。验证
在 requestUserInput 用例的
stop()之前注入一条必失败断言做变异,跑完后数残留的 fixture 进程:🤖 Generated with Claude Code