Nodejs AWS Serverless Lambda invokes another lambda in a loop does not work consistently

Hi,
I have been working on an application where i have a requirement to perform lambda.invoke from being inside another lambda, and invoked lambda will needs to work recursively until the array of items gets empty. So I have two lambdas as following:

  1. Lambda to start the process on array of JSON objects (let’s call this lambda as startLambda).
  2. Lambda to to perform actual process on the JSON data received from startLambda while it got invoked from startLambda. After performing process we remove one element from array of objects and invokes the self lambda to perform process until the array gets empty.
    While doing as explained above i have observed inconsistent behavior of lambda and its response as following:
  3. On first time triggering startLambda, it does not return any response.
  4. On second time triggering startLambda it does return some response, but it does not contain complete list of response which may have covered the processing of all the elements of predefined array of JSON object.
  5. On third time or more it does not show the same response as expected, and also it changes response every time, which is inconsistent and not reliable.

Can someone please help me how can i tackle this kind of requirement and also overcome the issue as i have explained above.

If you have any alternative solution to handle this requirement, please be my guest.

Thanks in advance.

~Mayur Bhatt