title: Why is my AWS Lambda function ending before finishing with no timeout message?
body: <p>I've been using AWS Lambda and testing with SAM local for nearly a year with no major issues. However, I've written a Lambda function which modifies some files with the S3 API.</p>
  <p>The function ends with a 502: Invalid lambda response received: Lambda returned &lt;class 'NoneType'&gt; instead of dict</p>
  <p>This is before my function has had a chance to finish...
  I've managed to condense the code to the following:</p>
  <pre><code>exports.handler = async (event, context) =&gt; {
      console.log(&quot;Goldi&quot;);
      await fish(event, context);
      console.log(&quot;Locks&quot;);
      return { statusCode: 200, body: &quot;Finished!&quot; };
  };
  </code></pre>
  <p>No matter whether I run this in SAM Local or upload to AWS Lambda, I get this output:</p>
  <pre><code>START RequestId: 6a30e157-3e9b-465e-a945-3e9f7fa2cd7e Version: $LATEST
  2022-01-12T18:36:27.601Z        6a30e157-3e9b-465e-a945-3e9f7fa2cd7e    INFO    Goldi
  2022-01-12T18:36:27.603Z        6a30e157-3e9b-465e-a945-3e9f7fa2cd7e    INFO    Some output from fish()...
  END RequestId: 6a30e157-3e9b-465e-a945-3e9f7fa2cd7e
  REPORT RequestId: 6a30e157-3e9b-465e-a945-3e9f7fa2cd7e  Init Duration: 0.18 ms  Duration: 12600.03 ms   Billed Duration: 12700 ms       Memory Size: 512 MB     Max Memory Used: 512 MB
  Invalid lambda response received: Lambda returned &lt;class 'NoneType'&gt; instead of dict
  2022-01-12 18:36:38 127.0.0.1 - - [12/Jan/2022 18:36:38] &quot;POST / HTTP/1.1&quot; 502 -
  </code></pre>
  <p>I've configured this Lambda function to have a timeout of several minutes and I do not call any functions in 'context'</p>
  <p>I've sunk several hours into trying to figure out how a Lambda function can end without any error message (from my code) or a timeout notice.</p>
  <p>Is this a known behaviour? Does anyone know how I can find out what causes the function to suddenly stop with no output?</p>