title: react-native start gives me "Watchman error: too many pending cache jobs"
body: <h1>Problem</h1>
  <p>When I create a bundle - the watchman crawl initially fails with &quot;<code>too many pending cache jobs</code>&quot;, which seems to slow down the bundling process:</p>
  <pre><code>$ react-native start --reset-cache
  </code></pre>
  <blockquote>
  <p>Loading dependency graph...jest-haste-map: Watchman crawl failed. Retrying once with node crawler.</p>
  <p>Usually this happens when watchman isn't running. Create an empty <code>.watchmanconfig</code> file in your project's root folder or initialize a git or hg repository in your project.</p>
  <p>Error: Watchman error: too many pending cache jobs. Make sure watchman is running for this project. See <a href="https://facebook.github.io/watchman/docs/troubleshooting.html" rel="nofollow noreferrer">https://facebook.github.io/watchman/docs/troubleshooting.html</a></p>
  </blockquote>
  <p>Also, these may be related:</p>
  <ul>
  <li>I can get rid of the error by excluding <code>node_modules</code> from the watch config</li>
  <li>Without the error, and the bundler starts in <strong>20 seconds</strong></li>
  <li>With the error, the craw takes 4 seconds, but the bundler starts in <strong>4 minutes</strong></li>
  </ul>
  <h1>Background</h1>
  <h2>Pre-bundle scripts</h2>
  <p>I run these before the bundler, to attempt to get more stability:</p>
  <pre class="lang-sh prettyprint-override"><code>watchman watch-del-all
  watchman shutdown-server
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288
  </code></pre>
  <h2>Watchman config file</h2>
  <p>I set my <code>.watchconfig</code> file to be extra permissable:</p>
  <pre><code>{
    &quot;ignore_dirs&quot;: [],
    &quot;fsevents_latency&quot;: 0.5,
    &quot;fsevents_try_resync&quot;: true
  }
  </code></pre>
  <h2>Watchman log</h2>
  <p>The crawl <strong>does complete</strong>, within a few seconds according to the full log</p>
  <pre class="lang-sh prettyprint-override"><code>$ tail -f /usr/local/var/run/watchman/coolman-state/log
  </code></pre>
  <pre><code>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 &lt;no build info set&gt; 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: &quot;sock&quot; wasn't present in Sockets
  22:08:28,805: [io 0x7f87ba000818 /Users/coolman/project/react-native-app] PERF: {&quot;ru_nvcsw&quot;: 1460, &quot;ru_nsignals&quot;: 0, &quot;ru_msgrcv&quot;: 0, &quot;ru_msgsnd&quot;: 0, &quot;ru_inblock&quot;: 0, &quot;ru_majflt&quot;: 0, &quot;ru_nswap&quot;: 0, &quot;ru_minflt&quot;: 28103, &quot;ru_ixrss&quot;: 0, &quot;ru_maxrss&quot;: 115109888, &quot;system_time&quot;: 2.9349970000000001, &quot;user_time&quot;: 1.327971, &quot;elapsed_time&quot;: 4.4614079999999996, &quot;pid&quot;: 29414, &quot;ru_idrss&quot;: 0, &quot;meta&quot;: {&quot;root&quot;: {&quot;watcher&quot;: &quot;fsevents&quot;, &quot;ticks&quot;: 2, &quot;number&quot;: 1, &quot;case_sensitive&quot;: false, &quot;recrawl_count&quot;: 0, &quot;path&quot;: &quot;/Users/coolman/project/react-native-app&quot;}}, &quot;version&quot;: &quot;4.9.0&quot;, &quot;ru_oublock&quot;: 0, &quot;ru_nivcsw&quot;: 2171, &quot;start_time&quot;: 1564952904.3444469, &quot;description&quot;: &quot;full-crawl&quot;}
  22:08:28,805: [io 0x7f87ba000818 /Users/coolman/project/react-native-app] crawl complete
  </code></pre>