Repository navigation
test(session): 离线收口用例改用已退出并回收的 pid,消除 ownerPid 4242 撞上活进程的 flake - #2340
Merged
Merged
Conversation
hostOccupancyLeaseHeld() 在 TTL 过期后仍对活着的 ownerPid fail-closed;两个 「租约已过期、daemon 不可发现」用例硬编码 4242 假定其已死,CI runner 上恰好 存在 pid 4242 时期望 status 0 拿到 1。改用仓库既有的 deadPid() 约定 (spawnSync 立即退出的子进程,确定 ESRCH),与 session-occupancy.test.ts 一致。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 25, 2026 11:51
This was referenced Oct 25, 2026
|
🚀 Released in v3.52.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.
背景
外部 PR #2270 新 head(merge
4662d02b3)的必需 CItest (3/3)偶发失败:根因
src/services/session-store.ts的hostOccupancyLeaseHeld()是有意的 fail-closed:TTL 过期后,只要
ownerPid对应的进程还活着(kill(pid,0)不返回 ESRCH),就仍然视为租约持有、拒绝离线收口。生产逻辑不动(注释已说明 pid 复用误报是接受的已知边界,start-identity 是后续 C-13)。问题在测试:两个「租约过期且 owner 已死」用例把
ownerPid硬编码为4242,假定它不存在。CI runner 上恰好有 pid 4242 的进程时,用例必红。证据:40187445363,shae7e4a80c2)该文件 22/22 全绿;process.pid)可逐字复现该失败。修复
改用仓库既有的
deadPid()约定(test/session-occupancy.test.ts:84同款):spawnSync(process.execPath, ['-e','0'])同步等待退出并回收,该 pid 被探测时确定 ESRCH。替换两处过期租约播种(390 / 447 行);活租约用例继续显式用process.pid,语义对照不变。验证
test/session-delete-cli.test.ts连跑 3 次 22/22 全绿;tsc --noEmit通过;bun run build通过。deadPid()换成process.pid(owner 活着)→ 该用例精确变红(1 failed / 21 passed),还原后恢复全绿,证明断言确实在区分 owner 存活性、修复是承重的。🤖 Generated with Claude Code