title: Using awaits with fs.watch() in node.js
body: <p>I have some code that talks connects to a redis and returns a promise like:</p>
  <pre><code>async connectionToRedisClient() {
      return await this.connect('connect')
      .then(() =&gt; {
          log.info('Connected');
      })
      .catch(() =&gt; log.error('Error connecting to redis'));
  }
  </code></pre>
  <p>Which is later used to wait for a successful connection before proceeding with an algorithm:</p>
  <pre><code>await connectionToRedisClient()
  </code></pre>
  <p>This all works fine on its own, and has done for some time now - however, I am adding the <code>fs.watch</code> function to trigger this code when a new file appears in a directory.</p>
  <p>The <code>fs.watch</code> code works fine, and attempts to execute the above code, but suddenly stops at the await and does not complete. My debugging leads to this code and only this code.</p>
  <p>If I remove the redis code then the code completes fine. Is there a problem using awaits in <code>fs.watch</code>? or do I have some mix up with sync &amp; async code here? Keep in mind that if I stop using <code>fs.watch</code>, the redis code is fine, so the problem isn't directly related to my redis code.</p>
  <p>See my <code>fs.watch</code> code for reference:</p>
  <pre><code>fs.watch('./targets', async (event, filename) =&gt; {
      console.log('event is: ' + event);
      if (filename === 'file.txt') {
         await main();
      } else {
          console.log('Incorrect file passed');
      }
  });
  </code></pre>