title: AWS Lambda Promise.all is never returning or await is not working with it
body: <p>So I have the below code.  When I run it locally it works as expected.  When I publish it to lambda it fails to get my S3 items.  I see that the promises get created for my request but the <code>return Promise.all(ps)</code> never returns with the expected values.  I have tried to change it in a few different ways but always nothing.  I updated my local env to be the same as lambda (node 8.10 and aws-sdk 2.290.0) and still it works locally but not when hosted.  </p>
  
  <p>The cloudwatch logs show that it ended and does not contain errors and ends in ~100ms.  </p>
  
  <p>I'm calling out to get 20 objects from s3 each 8k in size; I have added a break to only retrieve 1 record and the same happens... nothing.  </p>
  
  <pre><code>module.exports = async(messages) =&gt; {
    try {
  
      for (var rec of messages) {
        debug('rec',rec);
        let samples = await getRecordingPageSamples(rec.serialNumber,rec.recordingSet,rec.recording,rec.pages);
        //NEVER GETS HERE IN LAMBDA
        ...
      }
      //NEVER GETS HERE IN LAMBDA
      console.log('we are done here.');
    } catch (e) {
      console.log('unhandled',e);
    }
  };
  
  function getRecordingPageSamples(serialNumber,recordingSet,recording,pages){
    let ps = getObjectGenerator(pages.map(x=&gt;[process.env.s3EeegPageBucket,genRecordingSamplePath(serialNumber,recordingSet,recording,x)]));
    ps = ps.map( p=&gt; p.then(obj=&gt;{
      console.log('done',obj[1]);
      return obj.slice(0,2).concat([obj[1].split(s.FILE_NAME_SEP)[2],obj[2].Body.toString()]);
    }));
    // here ps is an array of promises ps [ Promise { &lt;pending&gt; } ]
    return Promise.all(ps);
  }
  
  function getObjectGenerator(list){
    let ps = [];
    for (let x of list){
      //DOES GET HERE IN LAMBDA
      console.log('requesting obj',x);
      ps.push( getObject(x[0],x[1]));
    }
    return ps;
  }
  
  const getObject = (bucket,key) =&gt; {
    return s3.getObject({
      Bucket: bucket, // Assuming this is an environment variable...
      Key: key
    })
      .promise()
      .then(data=&gt;{
        //NEVER GETS HERE IN LAMBDA
        console.log('got it',key);
        return [bucket,key,data];
      });
  </code></pre>
  
  <hr>
  
  <p>Problem solved.  There was another wrapper function above this module that was an async function but was not using the await keyword.  Rookie mistake!</p>