title: ES8 Immediately invoked async function expression
body: <p>I haven't seen these constructs used much but I've found myself writing them to make use of async / await in functions that wouldn't typically return a promise, for example</p>
  
  <pre><code>chan.consume(queue, (msg) =&gt; {
    this.pendingMsgs++; // executed immediately
    (async () =&gt; {
      await this.handleMessage(msg);
      this.pendingMsgs--;
      if (cancelled &amp;&amp; this.pendingMsgs === 0) {
         await chan.close();
         await this.amqpConnectionPool.release(conn);
      } 
    })();
  });
  </code></pre>
  
  <p>as opposed to </p>
  
  <pre><code>chan.consume(queue, async (msg) =&gt; { // external lib does not expect a return value from this callback
    this.pendingMsgs++;  // executed in promise context(?)
    await this.handleMessage(msg);
    this.pendingMsgs--;
      if (cancelled &amp;&amp; this.pendingMsgs === 0) {
         await chan.close();
         await this.amqpConnectionPool.release(conn);
      }
  });
  </code></pre>
  
  <p>or</p>
  
  <pre><code>chan.consume(queue, (msg) =&gt; {
    this.pendingMsgs++;  // no await - excess function decls &amp; nesting
    this.handleMessage(msg).then(() =&gt; {
      this.pendingMsgs--;
      if (cancelled &amp;&amp; this.pendingMsgs === 0) {
         chan.close().then(() =&gt; {
           this.amqpConnectionPool.release(conn);
         });
      }
    });
  });
  </code></pre>
  
  <p>Is this 'a thing'? Are there pitfalls here I should be aware of?
  What's the lowdown on use of async / await in these kind of situations?</p>