title: Called a lambda function once, it's executed twice
body: <p>This is more of a concern than a question, but still, has anyone experienced this before? Does anyone know how to prevent it?</p>
  
  <p>I have a lambda function (L1) which calls a second lambda function (L2) all written in NodeJs (runtime: Node.Js 8.10, and <code>aws-sdk</code> should be v2.488.0 - but I'm just pasting that from the documentation). The short story is that L1 is supposed to call L2, and when it does L2 is executed twice! I discovered this by writing logs to CloudWatch and I could see one L1 log and two L2 logs.</p>
  
  <p>Here's a simplified version of L1 and L2.</p>
  
  <p><strong>L1:</strong></p>
  
  <pre><code>const AWS = require('aws-sdk');
  const lambda = new AWS.Lambda();
  
  module.exports = {
      handler: async (event, context, callback) =&gt; {
          const lambdaParams = {
              FunctionName: 'L2',
              Qualifier: `dev`,
              Payload: JSON.stringify({}),
          };
  
          console.log(`Calling: ${JSON.stringify(lambdaParams)}`);
          return await lambda.invoke(lambdaParams).promise();
      },
  };
  </code></pre>
  
  <p><strong>L2:</strong></p>
  
  <pre><code>module.exports = {
      handler: async (event, context, callback) =&gt; {
          console.log(`L2 called`);
      },
  };
  </code></pre>
  
  <p>In CloudWatch I can see one <code>Calling ....</code> and two <code>L2 called</code>!</p>
  
  <p>BTW, this does not happen all the time. This is part of a step function process which was going to call L1 10k times. My code is written in a way that if L2 is executed twice (per one call), it will fail the whole process (because L2 inserts a record to DB only if it does not exist and fails if it does). So far, I managed to log this behaviour three times. All of them processing the same 10k items, facing the issue at a different iteration each time.</p>
  
  <p>Does anyone have the same experience? Or even better, knows how to make sure one call leads to exactly one execution?</p>