title: Not receiving all messages at receiver lambda from SQS with AWS serverless and NodeJS
body: <p>We created two lamdba functions using AWS Serverless and NodeJS one is sender and other is receiver, and in between these two there in one Standard SQS which is receiving data from sender lambda and it automatically triggers the receiver lambda function if any message arrives at SQS.</p>
  
  <p>Here, we are able to send all messages successfully from sender lambda to SQS(as per the logs), but at receiver lambda we are not getting all the messages.</p>
  
  <p>To test this scenario I sent 1000 messages from postman and tested that sender was sending all messages perfectly to SQS, but receiver was only getting random 986 messages out of it, some random messages have been missed in between.</p>
  
  <p><strong>I also tried the SQS type to FIFO instead of standard but it is not supported by lambda.</strong></p>
  
  <p>Here is the code for sender and receiver function:</p>
  
  <p>SENDER: </p>
  
  <pre><code>sender: () =&gt; {
      const sqs = new AWS.SQS({ apiVersion: "2019-08-09" });
      let body = [
          { id : "1" },
          { id : "2" },
          { id : "3" }
      ]
      let params = {
          DelaySeconds: 10,
          QueueUrl: url,
          MessageBody: JSON.stringify(body)
      };
      sqs.sendMessage(params, function (err, data) {
          if (err) {
              callback(true, null);
          } else {
              callback(false, data);
          }
      });
  }
  </code></pre>
  
  <p>RECEIVER :</p>
  
  <pre><code>receiver: () =&gt; {
      event.Records[0].body = JSON.parse(event.Records[0].body);
      async.timesSeries(event.Records[0].body.length, (i, next) =&gt; {
          const params = {
              TableName: "user",
              Key: {
                  id: "1"
              }
          };
          dynamoDb.get(params).promise()
              .then(result =&gt; {
                  //save user
              })
              .catch(error =&gt; {
                  //throw err
                  next();
              });
      }, () =&gt; {
          console.log("deleting message");
          const deleteParams = {
              QueueUrl: "queue_url",
              ReceiptHandle: event.Records[0].receiptHandle
          };
          sqs.deleteMessage(deleteParams, function (err, data) {
              if (err) {
                  //throw error
              } else {
                  //success
              }
          });
      });
  }
  </code></pre>