MoonshotAI / MoonshotAI/kimi-code
Windows 启动时文件监听器扫描 C:\ 根目录,报 EINVAL: lstat 'C:\swapfile.sys'
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
问题描述
Windows 上启动 kimi(工作目录 C:\Users\<用户名>),启动阶段固定打印 4 条 [unexpected] 错误,随后 CLI 正常启动、功能不受影响:
[unexpected] Error: EINVAL: invalid argument, lstat 'C:\swapfile.sys'
at async lstat (node:internal/fs/promises:1029:18)
at async ReaddirpStream._formatEntry (.../main.cjs:220320:56)
at async Promise.all (index 10)
at async ReaddirpStream._read (.../main.cjs:220263:23) {
errno: -4071,
code: 'EINVAL',
syscall: 'lstat',
path: 'C:\swapfile.sys'
}
根因分析
- 堆栈来自 readdirp(chokidar 系依赖),说明启动时某个文件监听器扫描到了
C:\盘符根目录(从工作目录向上查找配置/标记文件时,可能把盘符根目录也纳入了监听)。 swapfile.sys/pagefile.sys/hiberfil.sys是 Windows 内核独占锁定的系统文件,Node.js 对其lstat必返 EINVAL,属于 Windows 上文件监听器的经典问题(angular/angular-cli#30617、cypress-io/cypress#33586 等均有同样报告)。
期望行为
监听器忽略此类 EINVAL/EPERM 错误(或避免监听盘符根目录),保持启动日志干净。
环境
- OS: Windows 11
- kimi-code: 0.38.0(npm 当前最新版)
- Shell: Git Bash
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 by tracing the startup file-watcher setup that uses chokidar and its readdirp dependency, then reproduce the scan from a Windows working directory under C:. Confirm that locked files such as swapfile.sys no longer produce startup errors while normal file watching and CLI startup still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100