title: Why can I await this code but not use .then?
body: <p>Node.JS 10.15, serverless, lambdas, invoked locally</p>
  
  <p>SAMPLE A) This Works:</p>
  
  <pre><code>export async function main(event) {
      const marketName = marketIdToNameMap[event.marketId];
      const marketObject = marketDirectory[marketName];
      const marketClient = await marketObject.fetchClient();
  
      const marketTime = await marketObject.getTime(marketClient);
      console.log(marketTime);
  }
  </code></pre>
  
  <p>SAMPLE B) and this works:</p>
  
  <pre><code>export function main(event) {
      const marketName = marketIdToNameMap[event.marketId];
      const marketObject = marketDirectory[marketName];
  
      marketObject.fetchClient().then((marketClient)=&gt;{
          marketObject.getTime(marketClient).then((result) =&gt; {
              console.log('&lt;---------------&gt; marker 1 &lt;---------------&gt;');
              console.log(result);
          });
      });
  }
  </code></pre>
  
  <p>SAMPLE C) but this does not:</p>
  
  <pre><code>export async function main(event) {
      const marketName = marketIdToNameMap[event.marketId];
      const marketObject = marketDirectory[marketName];
      const marketClient = await marketObject.fetchClient();
  
      console.log('&lt;---------------&gt; marker 1 &lt;---------------&gt;');
  
      marketObject.getTime(marketClient).then((result) =&gt; {
          console.log('&lt;---------------&gt; marker 22 &lt;---------------&gt;');
          console.log(result);
      });
  }
  </code></pre>
  
  <p>the guts of getTime are for all examples:</p>
  
  <pre><code>function getTime(marketClient){
      return new Promise((resolve, reject) =&gt; {
          return marketClient.getTime((err, result) =&gt; {
              if (err) {
                  reject(err);
              }
              resolve(result);
          });
      }).catch(err =&gt; {
          throw err;
      });
  }
  </code></pre>
  
  <p>clearly, it seems to be an issue with mixing async/awaits with classic promise then-ables. I would <strong>expect</strong> SAMPLE C to work because getTime() is returning a promise. However, the code simply finishes silently, never hitting the second marker. I have to put the first marker there just to be sure any code is run at all. It feels like i should be able to mix async/await and thenables, but i must not be considering something here.</p>
  
  <p>@adrian, nope
  <a href="https://i.stack.imgur.com/LOr9o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LOr9o.png" alt="enter image description here"></a></p>