Skip to content

[Bug] chokidar 监听 node_modules 导致 CPU 100%(ENOSPC 错误) #2903

@wen-kai23

Description

@wen-kai23

Qinglong version

青龙 2.20 debian 版本

Steps to reproduce

青龙 2.20 debian 版本启动后 CPU 持续占用 100%+,错误日志显示 inotify watcher 数量超限。

What is expected?

环境信息

  • 青龙版本:2.20.0-1
  • 镜像:whyour/qinglong:debian
  • 系统:Ubuntu 22.04
  • Docker 版本:24.x

What is actually happening?

Error: ENOSPC: System limit for number of file watchers reached, watch '/ql' code: 'ENOSPC', syscall: 'watch', path: '/ql'

System Info

Any additional comments?

原因分析

容器内文件统计:

  • /ql 总文件数:约 9258 个
  • /ql/node_modules 文件数:约 8243 个
  • Linux 默认 inotify 限制:8192 个

chokidar 监听了整个 /ql 目录,包括 node_modules,导致 watcher 数量超限后疯狂重试,CPU 飙高。

建议修复

在 chokidar 配置中忽略 node_modules:

chokidar.watch('/ql', {
  ignored: ['**/node_modules/**', '**/.git/**']
})


echo 16384 | sudo tee /proc/sys/fs/inotify/max_user_watches

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions