Status: needs-info
所属:01 分诊记录。工单:ZCT-2113066013935316992。行号以 v3.16.2 为准。
Windows 用户连接 SSH 设备,4 次都在约 8s 报 Timed out after 8018ms waiting for the ZCode file lock,界面显示“连接超时”,阶段标签是 probe。同一会话里 setting.update 也 8s 锁超时,getSnapshot 两次约 8s。上一次会话同一路径 136ms 就连上了。
SSH 新连接 → connectSourceServerTarget(host/index.ts:1970)
└─ manager.connect,membershipIntent ?? "add"(sourceServerConnectionManager.ts:348)
└─ admitConnection(:826-831)→ intent=add → service.saveHost(remote-projects/connection-membership.ts)
└─ SQLite 写 hosts → await changed()(remote-projects/index.ts:162-181)
└─ publishProjectChange → settingService.update({})(services/src/node.ts:2162-2166)
└─ withAtomicFileLock(~/.zcode/v2/setting.json)(setting/settingService.ts:228)
└─ acquireFileLock 最多等 8s(fs/atomicFileUtils.ts:10)→ owner PID 被判“存活” → 超时
└─ 文案含 “Timed out” → remote-connection-timeout → UI “连接超时”;阶段标签停在默认值 probe
%USERPROFILE%\.zcode\v2\setting.json.lock(目录锁)。不是远端锁,远端设备没有参与。shared/src/node/atomicFileLock.ts:55-62(只有 ESRCH 算退出)、:72-88(锁年龄只对无 PID 的锁生效)。Windows 上 PID 被复用或进程无权打开(EPERM)都被当成存活,锁永久不回收。atomicFileLock.ts:218-224)。acquireFileLock):owner PID 已退出 → 2ms 回收;owner PID 存活或 EPERM → 8002ms 超时,文案与 cause EEXIST 与用户一致。限制:在 macOS 上模拟 EPERM,未在 Windows 上运行。锁的持有者(现有材料区分不了):
rmdir 失败,失败被吞)。7c9139f8b0 已用 boot_id + starttime 解决同类问题;Windows 可用进程创建时间),或对有 PID 的锁也设年龄上限。remote-connection-timeout,阶段标签不应停在 probe。未修复。v3.16.2..HEAD 没有改 atomicFileLock.ts、settingService.ts、atomicFileUtils.ts、remote-projects、connectionErrors;e69dc8d551、7c9139f8b0 修的是远端 server-cli 的锁。
Get-ChildItem -Force "$env:USERPROFILE\.zcode\v2\setting.json.lock"
Get-Content "$env:USERPROFILE\.zcode\v2\setting.json.lock\owner-*.json" # pid、createdAt
Get-Process -Id <pid>; tasklist /FI "PID eq <pid>" /V; Get-Process ZCode
echo $env:HOME
PID 不是当前 ZCode 或启动晚于 createdAt → H1;PID 等于当前 Main/Host 且 createdAt 晚于本次启动 → H2。另问重启 ZCode 后是否恢复。
临时处理:从托盘完全退出 ZCode,确认没有 ZCode.exe,删除 setting.json.lock 目录后再启动。