远程 WSL 模式打开 drvfs 挂载盘上的大型 pnpm 项目,开新会话一直转圈(zcode-server 卡死于 9p RPC)
Open
Nobody has claimed this yet.
priority: P2
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
使用环境
- 操作系统:Windows 11 + WSL2(Ubuntu 24.04,内核 6.18.33.2-microsoft-standard-WSL2)
- ZCode 版本:0.16.3(0.16.1 同样存在)
- 模型通道:智谱 GLM(builtin:bigmodel-coding-plan)
- 项目位置:WSL 挂载的 Windows NTFS 盘(drvfs,路径形如
/mnt/<盘符>/...),非 WSL 原生盘
问题描述
- Windows 端 ZCode 以「远程 WSL」模式打开位于 drvfs 挂载盘上的项目(前端含 pnpm 安装的
node_modules,约 6 万文件 / 9 千目录 / 3 千符号链接) - 新建会话后一直转圈,会话无法初始化
- WSL 侧出现
zcode-server进程永久卡死于 D 状态(不可中断睡眠),内核wchan为p9_client_rpc(9p 文件系统 RPC 永远等不到响应)
复现步骤
- 项目位于
/mnt/<盘符>(drvfs 挂载),含大型frontend/node_modules - ZCode 以远程 WSL 方式打开该项目(或升级后自动恢复历史 workspace)
- 新建会话 → 一直转圈,初始化完成不了
根因分析(已通过 /proc 诊断确认)
- 卡死线程内核栈:
p9_client_rpc → v9fs_vfs_lookup / p9_client_clunk → inotify_add_watch / statx - 读取
/proc/<pid>/syscall+/proc/<pid>/mem确认卡住时访问的路径为node_modules/.pnpm/<pkg>@<version>/node_modules/<pkg>/docs/.../xxx.md类深层路径 zcode-server.cjs含 100 处recursive: true及IFileWatcherService/autoRefreshWatchPaths/fsWatcher—— server 对 workspace 根目录建立了递归文件监听- 递归监听(Node
fs.watchrecursive / libuv 实现)无差别遍历整个目录树,不读取.gitignore,node_modules被完整遍历:每目录 1 次inotify_add_watch+ 每文件 1 次statx,合计约 7 万次文件系统操作 - drvfs(9p)上每次操作均为跨进程 RPC(实测单次 stat ≈ 2.4ms),遍历需数分钟,形成持续 9p 请求风暴
- 9p 协议无超时机制:风暴中任一个 RPC 处理挂起即永久无响应,进程 D 状态卡死 → 会话初始化永远完不成 → UI 转圈
期望 vs 实际
- 期望:递归监听应排除
node_modules等大目录(如 watchpack/chokidar 默认行为),或对 drvfs/9p 上的递归遍历提供超时/保护;项目在 drvfs 挂载盘上时新会话应正常初始化 - 实际:递归监听遍历
node_modules触发 9p RPC 风暴,server 永久卡死,新会话无限转圈;且卡死进程无法 kill,只能wsl --shutdown重启整个 WSL
影响范围
- 项目位于 drvfs 挂载盘时必然触发(WSL 用户常见工作流);项目在 WSL 原生 ext4 盘上无此问题(inotify 为本地内核操作,不走 9p)
日志
WSL 侧 /root/.zcode/cli/log/zcode-*.jsonl、/root/.zcode/v2/logs/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with zcode-server.cjs and the IFileWatcherService, autoRefreshWatchPaths, and fsWatcher entry points, focusing on the recursive: true watcher paths. Reproduce the remote WSL case on a drvfs project with a large frontend/node_modules tree and consult the listed WSL logs. Done means a new session initializes on drvfs without hanging in 9p activity or recursively traversing the large dependency tree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, node.js
- Domain
- devtools, operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100