Skip to content

Fix ENOSPC error from chokidar monitoring node_modules#2919

Draft
Copilot wants to merge 4 commits intodevelopfrom
copilot/fix-chokidar-enospc-error
Draft

Fix ENOSPC error from chokidar monitoring node_modules#2919
Copilot wants to merge 4 commits intodevelopfrom
copilot/fix-chokidar-enospc-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

Chokidar was monitoring the deps directory including node_modules symlinks, exhausting inotify watchers (~8243 files in node_modules vs 8192 limit) and causing ENOSPC errors with 100% CPU from retry loops.

Changes

  • Add node_modules and .git to chokidar ignored patterns in back/loaders/deps.ts
  • Use properly anchored regex patterns to avoid false positives (e.g., my_node_modules_backup.txt still watched)
const watcher = chokidar.watch(source, {
  ignored: [
    /(^|[\/\\])\../, // ignore dotfiles
    /(^|[\/\\])node_modules([\/\\]|$)/, // ignore node_modules
    /(^|[\/\\])\.git([\/\\]|$)/, // ignore .git
  ],
  persistent: true,
});

Patterns match only actual directories at any path depth, consistent with existing dotfiles pattern.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] chokidar 监听 node_modules 导致 CPU 100%(ENOSPC 错误)</issue_title>
<issue_description>### 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
</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
qinglong Ready Ready Preview, Comment Jan 29, 2026 11:39am
qinglong-back Ready Ready Preview, Comment Jan 29, 2026 11:39am

Copilot AI and others added 3 commits January 29, 2026 11:30
…PC error

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix chokidar monitoring causing CPU 100% due to ENOSPC error Fix ENOSPC error from chokidar monitoring node_modules Jan 29, 2026
Copilot AI requested a review from whyour January 29, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants