watchman: MacOS: Packing rn's bundle always stuck with Recrawled

I’m facing many ‘Recrawled’ problems recently.They stuck me in the packing process.The total process takes me an hour and a half what took me just several minutes before. I have solved several problems with raising the default per-process descriptor limit and updating the ruby version(other packages with the same updating). But I have the last problem with the info of ‘FSEvents flag’, I have no idea to resolve it Recrawled this watch 1 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run: 'watchman watch-del '/Users/lanleilei/temp/mobile' ; watchman watch-project '/Users/lanleilei/temp/mobile' '

MacOS: 11.6 Big Sur ruby: 2.7.5p203 watchman: 2021.12.06.00

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 110
  • Comments: 59 (1 by maintainers)

Most upvoted comments

Same issue here, really annoying. I had to run watchman watch-del-all regularly to keep this away temporarily.

watchman watch-del-all

This worked for me.

  • macOS Monterey 12.3.1
  • M1 Pro

I had this issue since moving to M1 with Monterey.

And I fixed this by modifying my .watchmanconfig as follows;

{ "fsevents_latency": 0.05, "fsevents_try_resync": "true", "prefer_split_fsevents_watcher": "true" }

The default for fsevents_latency is 0.01 in later versions of Watchman. By increasing we allow the system to batch more change notifications together.

Then run; watchman shutdown-server, and then try running Watchman again.

You can refer to: https://facebook.github.io/watchman/docs/config.html#fsevents-latency

For me this started happening since I switched to a MacBook with M1 chip. Never have seen this before.

I have also been experiencing this issue for the last month or so.

watchman warning:  Recrawled this watch 35 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run: ...

I’ve seen that warning in one standard React Native project and one Expo project.

I got an M1 Mac at around the same time the issue started happening, so I’m not sure if the issue is related to the new architecture or to the fact that the version of watchman that was released around then is problematic.

for MacOS M1 solved for me; $ watchman shutdown-server $ brew update $ brew reinstall watchman

for more question; https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl

watchman watch-del-all

This worked for me.

  • macOS Monterey 12.3.1
  • M1 Pro

That doesn’t work for long, my system is the same…

Well, i have the same issue, but my solution to that was reseting the Watchman, like this

https://stackoverflow.com/questions/49443341/watchman-crawl-failed-retrying-once-with-node-crawler

I am also seeing

‘Recrawled this watch 21 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl

after moving development to an M1 Macbook

any updates?

for MacOS M1 solved for me; $ watchman shutdown-server $ brew update $ brew reinstall watchman

for more question; https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl

I ran this and brew upgraded watchman to 2023.08.28.00 but I still get the same issue on a MacBook Pro with M1 Max

watchman warning:  Recrawled this watch 1 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/###' ; watchman watch-project '/Users/###'`

with 2023.10.09.00 I’m also getting this warning.

warning: Watchman `query` returned a warning: Recrawled this watch 3 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/joern.zaefferer/dev/mytonies-app' ; watchman watch-project '/Users/joern.zaefferer/dev/mytonies-app'`

I can clear the warning, but it will come back pretty quickly.

I’ve checked https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl and did not find any mention of MustScanSubDirs UserDroppedTo resolve.

Any idea what ‘MustScanSubDirs UserDroppedTo resolve’ means? It seems like this GitHub issue is one of the very few pages that Google can find that mention it at all.

Searching within this repo, there’s only one occurrence of MustScanSubDirs: https://github.com/facebook/watchman/blob/28b3a655a2de1b7940ca67440e7489604d199fbb/watchman/watcher/fsevents.cpp#L73

This also shows up in the fsevents package, which looks like an unrelated nodejs wrapper around fsevents: https://github.com/search?q=repo%3Afsevents%2Ffsevents MustScanSubDirs&type=code They added handling of MustScanSubDirs back in April: https://github.com/fsevents/fsevents/commit/a77340f4f96a6e02cd5bfabaaebd4e10535ee533

In Apple’s docs I found this page: https://developer.apple.com/documentation/coreservices/1455361-fseventstreameventflags/kfseventstreameventflagmustscansubdirs/

Your application must rescan not just the directory given in the event, but all its children, recursively. This can happen if there was a problem whereby events were coalesced hierarchically. For example, an event in /Users/jsmith/Music and an event in /Users/jsmith/Pictures might be coalesced into an event with this flag set and path=/Users/jsmith. If this flag is set you may be able to get an idea of whether the bottleneck happened in the kernel (less likely) or in your client (more likely) by checking for the presence of the informational flags kFSEventStreamEventFlagUserDropped or kFSEventStreamEventFlagKernelDropped.

Since the warning mentions both MustScanSubDirs and UserDroppedTo I guess this means we can kFSEventStreamEventFlagMustScanSubDirs and kFSEventStreamEventFlagUserDropped. Aka “the bottleneck happened in your client”.

I know way too little about fsevents to do anything with that though.

And I fixed this by modifying my .watchmanconfig as follows;

{ "fsevents_latency": 0.05, "fsevents_try_resync": "true", "prefer_split_fsevents_watcher": "true" }

My watchman crashes with this config and I cannot start metro at all. Here’s the output:

jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: A non-recoverable condition has triggered.  Watchman needs your help!
The triggering condition was at timestamp=1659521102: opendir(/Users/uloco/Source/smokeless/smokeless-react-native/ios/Pods/Flipper-Boost-iOSX/boost/stl_interfaces) -> Too many open files
All requests will continue to fail with this message until you resolve
the underlying problem.  You will find more information on fixing this at
https://facebook.github.io/watchman/docs/troubleshooting.html#poison-opendir. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.
/Users/uloco/Source/smokeless/smokeless-react-native/node_modules/metro-hermes-compiler/src/emhermesc.js:77
          throw ex;
          ^

Error: A non-recoverable condition has triggered.  Watchman needs your help!
The triggering condition was at timestamp=1659521102: opendir(/Users/uloco/Source/smokeless/smokeless-react-native/ios/Pods/Flipper-Boost-iOSX/boost/stl_interfaces) -> Too many open files
All requests will continue to fail with this message until you resolve
the underlying problem.  You will find more information on fixing this at
https://facebook.github.io/watchman/docs/troubleshooting.html#poison-opendir

    at ChildProcess.<anonymous> (/Users/uloco/Source/smokeless/smokeless-react-native/node_modules/fb-watchman/index.js:207:21)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
Emitted 'error' event on WatchmanWatcher instance at:
    at Client.<anonymous> (/Users/uloco/Source/smokeless/smokeless-react-native/node_modules/metro/node_modules/jest-haste-map/build/watchers/WatchmanWatcher.js:150:10)
    at Client.emit (node:events:390:28)
    at ChildProcess.<anonymous> (/Users/uloco/Source/smokeless/smokeless-react-native/node_modules/fb-watchman/index.js:214:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  watchmanResponse: {
    version: '2022.07.04.00',
    error: 'A non-recoverable condition has triggered.  Watchman needs your help!\n' +
      'The triggering condition was at timestamp=1659521102: opendir(/Users/uloco/Source/smokeless/smokeless-react-native/ios/Pods/Flipper-Boost-iOSX/boost/stl_interfaces) -> Too many open files\n' +
      'All requests will continue to fail with this message until you resolve\n' +
      'the underlying problem.  You will find more information on fixing this at\n' +
      'https://facebook.github.io/watchman/docs/troubleshooting.html#poison-opendir\n'
  }
}

I can confirm I’m experiencing this issue with watchman version 2022.03.21.00 This started when I switched from an intel based mac to arm64

watchman 2022.03.21.00
Monterey 12.3
M1 Pro

Shutting down the server and reinstalling it via brew did not solve my issue, warnings come back shortly.

watchman warning: Recrawled this watch 45 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run: watchman watch-del '/Users/rodrigodiasdefigueiredo/Desktop/test-app' ; watchman watch-project '/Users/rodrigodiasdefigueiredo/Desktop/test-app

I’m using a MacBook air M1, react-native. 0.67.2. and MacOs Monterey Ps: I’m not using expo!

I got an M1 Mac at around the same time the issue started happening, so I’m not sure if the issue is related to the new architecture or to the fact that the version of watchman that was released around then is problematic.

I suspect it’s related to a watchman change in recent releases, I’m seeing it on an Intel Mac here.

Bumping this issue, still happening in 2023 on macOS Monterey 12.6, on a MacBook Pro (16", 2019, not M1). Is there a solution which is compatible with recent macOS versions?

Any update on this, same problem here after migrating to m1 mac

This is happening to me as well when running jest tests on a NextJS project (not react native):

$ yarn test
yarn run v1.22.17
$ jest
watchman warning:  Recrawled this watch 27 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/ryanparker/GitHub/parliamentarian' ; watchman watch-project '/Users/ryanparker/GitHub/parliamentarian'`

Clearing the warning does not resolve the issue.

Using M1 Max Macbook Pro on Monterey 12.2.1

Acording to https://facebook.github.io/watchman/docs/cookies#limitation-macos-fsevents I add { “ignore_dirs”: [“build”, “ios”, “android”, “.git”] } into .watchmanconfig of project’s root path, and then restart my Mac, it works.

For future Googlers: I fixed the issue eventually by just uninstalling watchman. 🙃 (Obviously only helps people who don’t need watchman directly, maybe you installed it incidentally.) It was coming up because of running Jest, and apparently it doesn’t need to be installed for that to run, and was causing issues with Jest.

it keeps showing this to me

watchman warning: Recrawled this watch 9 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run:

I’ve tried many things, but none solved it

my .watchmanconfig is {}

@Harris-Miller I was able to fix this using the troubleshooting guide on the Watchman docs here and [here] (https://facebook.github.io/watchman/docs/install.html#system-specific-preparation).

TL;DR Run the following commands to increase the per-process descriptor limit:

$ sudo sysctl -w kern.maxfiles=10485760
$ sudo sysctl -w kern.maxfilesperproc=1048576

To persist this change across reboots, create a file at /etc/sysctl.conf if it doesn’t already exist. Add the following into the file.

kern.maxfiles=10485760
kern.maxfilesperproc=1048576

https://facebook.github.io/watchman/docs/install.html#system-specific-preparation

The manual says Only applicable on macOS 10.6 and earlier. Just tried it on M1 Monterey, the issue still here.

upd. This approach also wasn’t helpful https://superuser.com/questions/1634286/how-do-i-increase-the-max-open-files-in-macos-big-sur

@sergtimosh that’s right. See https://github.com/facebook/watchman/issues/880#issuecomment-749687420 for confirmation. In theory nothing is required for macOS 10.7+

The same issue on M1 Mac Book Pro.

warning: Watchman `watch-project` returned a warning: Recrawled this watch 47 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/langke/Developer/myapp' ; watchman watch-project '/Users/langke/Developer/myapp``

Same problem here, using M2 Air Ventura 13.0

I’ve got this error when using the config above

All requests will continue to fail with this message until you resolve the underlying problem. You will find more information on fixing this at https://facebook.github.io/watchman/docs/troubleshooting.html#poison-opendir. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting

Any updates on this issue?

Macbook Pro 2018 fresh installed has same issue.

@jason0x43

and I’ve seen it a few times on an Intel Mac I setup last month.

then it’s related to the latest watchman versions. As I mentioned earlier the MacBook I was setting up first doesn’t had this issue(versions 2021.10.18.00 and 2021.09.06.00). The one I started to work with on December (watchman: 2021.12.20.00) was spitting this Recrawled message into the output.