Repository navigation
test(tmux): 尸体夹具改等确定信号,tmux 不回收 pane 进程时从内核取退出码 - #2476
Merged
Merged
Conversation
尸体组 beforeEach 的 waitForDeadPane 只认 tmux 发布的 pane_dead_status,而 tmux 只有回收了 pane 进程才会发布;CI 上它在整个等待窗口(240 次读、7.5s) 都没回收,夹具读到「已死、无码」而红(#2459)。改成与后端(#2457)同一个 确定信号:pane 已死后,tmux 发布了状态就用它,没发布但进程仍是服务端未回收 的僵尸时读内核记下的退出码。读数上限保留,只覆盖 tmux 发现 pane 死亡这一步; 用尽时把最后看到的原始状态带进失败信息,区分饥饿与真失败。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 28, 2026 09:04
Owner
Author
|
合后核验:落地提交 19096f2(标题带 #2476、正文为空),落地树与「master 8c4bdd8 + 审过的 head e7bc2e6」逐一相同;master 上 19096f2 的 CI 已开跑(run 40690311693)。 交叉复审提的两条可选 P3,留作记录(都不影响合入):
|
deepcoldy
pushed a commit
to darylchen97/botmux
that referenced
this pull request
Oct 28, 2026
# Conflicts: # test/tmux-pipe-exit-code.test.ts
deepcoldy
pushed a commit
to darylchen97/botmux
that referenced
this pull request
Oct 28, 2026
deepcoldy#2476 的 waitForDeadPane 改由内核记录补 tmux 未回收 pane 的退出码, 替代本夹具原有的 run-shell 一次性唤醒;生产路径两者互补(nudge 先于 kernel fallback)。deepcoldy#2453 实验室链式 remain-on-exit failed,旧版拒绝 该值,describe 按真实 tmux 版本 >=3.2 skip。 Co-Authored-By: Claude Code <[email protected]>
This was referenced Oct 28, 2026
|
🚀 Released in v3.55.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.
修 #2459 的测试夹具残余(该 issue 已于 09:18 以 #2457 为由关闭,但第五个实例发生在 #2457 之后,见 评论)。
现象
#2457 合入后,#2439 同步到 a17dd9e 的 head
e937b14ae上,run 40635916436 / bun-test(attempt 1)红在test/tmux-pipe-exit-code.test.ts:失败点不在报红的那条用例里,而在第二个 describe(尸体组)公共
beforeEach的夹具waitForDeadPane。bun 会把 hook 的失败记在当时正要进入的用例名上。夹具读了 240 次(7.5s),pane 一直是「已死、状态为空」。同一次 run 里,生产路径的三条真实退出码用例(77 / 127 / exit 3)、信号死亡两条,以及 #2457 的三条实验室用例全部通过。所以生产侧已经由 #2457 修好,这次红的是测试夹具。#2459 第四个实例里尸体组的另一条红(
delivers the synchronous corpse exit …7700ms)也是这个夹具。根因
和 #2453 / #2457 是同一个机制:tmux 只有
waitpid()回收了 pane 进程之后,才会发布#{pane_dead_status}。在那之前 pane 读作1:(已死、无码),而 CI 上 tmux 有时整段时间都不回收。夹具只认 tmux 发布的状态,按读取次数等它变成非空,等多久都等不到。#2439 首审建议改成「等确定的信号(如 tmux 钩子),或者单独放宽这个夹具的预算」。我实测过钩子:在不回收子进程的服务端上(屏蔽 SIGCHLD 起服务端),
exit 77的尸体一直是1:,pane-died钩子不触发;正常服务端上是1:77,钩子触发。也就是说钩子和状态一样要等 tmux 回收,帮不上;放宽预算则只是把等待拉长,tmux 不回收时照样等不到。修法(纯测试改动)
把
waitForDeadPane提到模块顶层,改等确定的信号,也就是后端(#2457)现在用的那一个:#{pane_pid}:#{pid};readUnreapedPaneExit,与生产代码同一个函数);seen)带进失败 diff,能分清是哪种问题:0:…),饥饿或者 CLI 没退出;beforeEach的前提断言改成toMatchObject({ dead: true, status: '77' }),失败时 diff 里会带上seen。回归测试与复现
exit 77的尸体会话,夹具必须拿到77。isolate-run,4 核;另起 6 个空转进程压满 CPU,8 个 worker 并发、各循环 3 轮):bun test跑整个tmux-pipe-exit-code.test.ts,24 轮共 816 例全部通过,每轮 115–118s(空载约 40s)。本机 tmux 3.3a 加压造不出「不回收」状态,所以压测只证明没有引入回归;能确定复现的是上面那条实验室用例和它的变异。验证
test/tmux-pipe-exit-code.test.ts+test-hygiene:vitest 60 例全绿;bun test --timeout=120000跑本文件 34 例全绿。src/零改动。🤖 Generated with Claude Code