Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine why my AWS Lambda function is quitting without an error?

I have a fairly complex lambda function that is quitting mid-operation with no apparent explanation.

It is no where near its time or memory limit and it suddenly just has an END and REPORT in the logs with no errors reported.

Note that it does not hang; it is a very short execution. Is there a way that something in Node can Segfault without it causing an error to be reported?

How do I dig deeper into this? I have audited the code many times over, and it exits very deep in the loop with a parallel async command running. I am not detecting an error being thrown from any of the callbacks. It simply stops.

like image 657
David Avatar asked Sep 15 '25 12:09

David


2 Answers

After a fairly deep investigation, I believe the issue is that AWS Lambda is terminating the execution because there are no remaining processes waiting. Keep in mind that by default, lambda does not stop execution just because you call the main callback or context and will keep executing. Unless a special flag in the context is set, it will continue to operate until timeout or until all the processes are finished. In my case, I tracked it down into an error in the node-apn package where a promise was not coming back after a push notification. Not sure of a resolution besides taking it out for now.

like image 117
David Avatar answered Sep 18 '25 10:09

David


I had this after missing an await before an async function call.

I spent far too long going down the rabbit hole of trying to work out why it was failing at the last point it logged - which was always the same every run (by chance, or rather the time it took).

like image 45
Joe Avatar answered Sep 18 '25 10:09

Joe