当我创建捆绑包时-守卫爬行最初会失败,并显示“ too many pending cache jobs
”,这似乎会减慢捆绑过程:
$ react-native start --reset-cache
正在加载依赖关系图...开玩笑的贴图:监视程序爬网失败。使用节点搜寻器重试一次。
通常,这种情况会在守卫未运行时发生。在项目的根文件夹中创建一个空的
.watchmanconfig
文件,或在项目中初始化git或hg存储库。错误:Watchman错误:暂挂的缓存作业过多。确保守卫正在为此项目运行。参见https://facebook.github.io/watchman/docs/troubleshooting.html
此外,这些可能与以下内容有关:
node_modules
来消除错误我在捆绑器之前运行这些命令,以尝试获得更高的稳定性:
watchman watch-del-all
watchman shutdown-server
sudo sysctl -w kern.maxfiles=5242880
sudo sysctl -w kern.maxfilesperproc=524288
我将我的.watchconfig
文件设置为额外允许的:
{
"ignore_dirs": [],
"fsevents_latency": 0.5,
"fsevents_try_resync": true
}
根据完整的日志,在几秒钟内完成抓取
$ tail -f /usr/local/var/run/watchman/coolman-state/log
22:08:24,193: [client=0x7ff4a9686d98:stm=0x7ff4a9b2de00:pid=0] send_error_response: too many pending cache jobs
22:08:24,340: [listener] Watchman 4.9.0 <no build info set> starting up on coolman
22:08:24,341: [listener] path /Users/coolman/project/react-native-app is on filesystem type apfs
22:08:24,342: [listener] root /Users/coolman/project/react-native-app using watcher mechanism fsevents (auto was requested)
22:08:24,344: [listener] file limit is 2560 kern.maxfilesperproc=524288
22:08:24,344: [listener] raised file limit to 524288
22:08:24,345: [listener] launchd: "sock" wasn't present in Sockets
22:08:28,805: [io 0x7f87ba000818 /Users/coolman/project/react-native-app] PERF: {"ru_nvcsw": 1460, "ru_nsignals": 0, "ru_msgrcv": 0, "ru_msgsnd": 0, "ru_inblock": 0, "ru_majflt": 0, "ru_nswap": 0, "ru_minflt": 28103, "ru_ixrss": 0, "ru_maxrss": 115109888, "system_time": 2.9349970000000001, "user_time": 1.327971, "elapsed_time": 4.4614079999999996, "pid": 29414, "ru_idrss": 0, "meta": {"root": {"watcher": "fsevents", "ticks": 2, "number": 1, "case_sensitive": false, "recrawl_count": 0, "path": "/Users/coolman/project/react-native-app"}}, "version": "4.9.0", "ru_oublock": 0, "ru_nivcsw": 2171, "start_time": 1564952904.3444469, "description": "full-crawl"}
22:08:28,805: [io 0x7f87ba000818 /Users/coolman/project/react-native-app] crawl complete
答案 0 :(得分:0)
在我的"content_hash_max_items": 500000
中添加.watchmanconfig
可以为我解决。
听起来像您需要调整工作负载的元数据缓存大小;当watchman尝试插入比配置更多的缓存条目时,将发生该错误。
您可以在
.watchmanconfig
文件中指定较大的值:
content_hash_max_items
与content.sha1hex
元数据相关,默认为131072
。一个相关的选项是content_hash_max_warm_per_settle
,默认为1024
,这会使每个定居点最多评估这么多项目。symlink_target_max_items
默认为32768
。在查询请求符号链接目标的情况下,此缓存用于readlink
。这不太可能是您遇到的问题。我建议运行
find /Users/coolman/project/react-native-app | wc -l
来获取项目中当前文件的数量上限,并以此来确定这些缓存的大小;如果文件多于默认值,则应相应提高这些缓存设置。我不建议将
fsevents_latency
参数从默认值更改;您能否就导致您进行更改的原因分享更多背景信息?