After going through the crisis, any new lambda user has left.
As suggested, you can use context.done to stop. However , this is not recommended as it is only possible because of the historical versions of runj versions.
why does this timeout occur?
Your lambda may fall into the last line of your code and continue to work. Well, actually it is waiting for something, because the event loop will be empty.
what does it mean?
In nodejs, when you perform an async operation and register a callback function that will be executed after the operation is completed, the registration is sorted in the event loop.
On one line, this is an event loop that knows which callback function should execute when the async operation completes. But this is to another thread :)
back to lambda
Given the above information, it follows that the lambda should not stop before the empty chain of events is reached - as this means that the subsequent procedure will not be performed after some asynchronous return of goods.
What if you still need to stop execution manually? regardless of the state of the event loop? At the beginning of the function, do:
context.callbackWaitsForEmptyEventLoop = false
And then use the third parameter that you get in the handler signature. This is a callback .
callback parameter
This is the function that you call when you want to complete the execution.
If you call it without parameters or with the first parameter as zero, and the text as the second parameter, it is considered a successful call.
To make lambda execution fail, you can call the callback function with some non-zero value as the first parameter.