-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix "too many files open" error when watching with-antd example #1022
Conversation
漫游整体变更的高层摘要是: 更改
诗
Note Pull Request Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
目前的解决方式:
|
crates/mako/src/watch.rs
Outdated
"node_modules", | ||
".DS_Store", | ||
".node", | ||
self.compiler.context.config.output.path.to_str().unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行应该只在 root 下生效,ancestors 也加会有副作用,如果上级目录下真有用到 dist 就有问题了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已处理
crates/mako/src/watch.rs
Outdated
ignore_list.iter().any(|ignored| path.ends_with(ignored)) | ||
ignore_list | ||
.iter() | ||
.any(|ignored| path.strip_prefix(ignored.to_str().unwrap()).is_some()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前的逻辑是判断 ends_with,为啥这里是 strip_prefix(前缀)?没看懂。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前传入的是类似 dist 的字符串,所以判断是以 dist 结尾,现在传入的是整个路径,比如 /a/b/node_modules,所以判断是以这个开头的就忽略
crates/mako/src/watch.rs
Outdated
]; | ||
|
||
let mut dirs = vec![]; | ||
self.root.ancestors().for_each(|path| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里补个 why 的注释。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已添加
补充下 dumi 的场景。
|
Notes: watch 最早的逻辑是,read_dir root,每个文件或目录基于 should_ignore_watch 忽略。 #864 为了支持 linked 的场景,更改后的逻辑是,在之前的基础上,会收集所有 module_graph 中带 package.json 模块的路径,且这些路径不能是 root 下,或者 root 的上层目录。那么会额外监听这些目录。 然后遇到的一个场景是 with-antd 的 monorepo 场景,其 node_modules 大量文件在上层,所以会 watch 到太多文件,导致「too many files open」报错,解法是忽略所有上层目录,见 PR #1022 |
…1022) * fix: fix "too many files open" error when watching with-antd example * fix: include dist dictionary of root's parent dictionary when watching --------- Co-authored-by: zp365238 <zp365238@antgroup.com> Co-authored-by: pshu <pishu.spf@antfin.com>
* feat: ✨ add [d]ynamic [r]equire runtime function * refactor: 🎨 dynamic import require process with interop * test: ✅ add test case * test: ✅ import context module adjust to dynamic import * release: @umijs/mako@0.4.18-canary.20240517.1 * chore: ⬆️ mako 0.4.18-canary.20240517.1 * chore: ⬆️ update pnpm-lock * typo * fix: fix "too many files open" error when watching with-antd example (#1022) * fix: fix "too many files open" error when watching with-antd example * fix: include dist dictionary of root's parent dictionary when watching --------- Co-authored-by: zp365238 <zp365238@antgroup.com> Co-authored-by: pshu <pishu.spf@antfin.com> * chore: 🔧 adjust puffin for easy profile for both long time compiling and watch mode (#1168) * chore: 🔧 adjust puffin for easy profile for long time compiling * refactor: 🎨 move profile logic to profile app * fix: decorator visitor should run before preset env (#1176) * test: ✅ add runtime assert in decorator and target to chrome 40 * fix: 🐛 move decorator before preset_env * add comment on decorators * feat: add watch.ignorePaths config (#1179) * release: @umijs/mako@0.4.18-canary.20240520.1 * chore: ⬆️ v0.4.18-canary.20240520.1 * chore: ⬆️ update pnpm-lock --------- Co-authored-by: zhangpanweb <37805064+zhangpanweb@users.noreply.github.com> Co-authored-by: zp365238 <zp365238@antgroup.com> Co-authored-by: chencheng (云谦) <sorrycc@gmail.com>
close: #991
出现的原因: with-antd 是 monorepo 中的一包,其 node_modules 会 link 到最外层 node_modules,之前的判断中,判断的是,执行目录的 node_modules 会被 ignore,但是上层并不会,导致需要 watch 的文件过多
解决方式:将上层目录的 node_modules 也加入到 ignore 范畴
Summary by CodeRabbit
watch_dir_recursive
方法现在支持接受要忽略的目录列表。watch_file_or_dir
方法现在接受路径数组来忽略指定路径。should_ignore_watch
方法增强,检查忽略列表中的路径前缀。watch_dir_recursive
方法,引入新的get_ignore_list
方法,根据特定条件动态构建忽略列表。watch_dir_recursive
方法中的ignore_list
参数从&str
数组更改为PathBuf
数组。