Is it possible for Lambda to continue processing after returning a response like the status code is 202
then Lambda will have to call a request before ending the Lambda?
Regarding background processes or callbacks initiated before the function returns a response, from the Lambda docs:
Background processes or callbacks initiated by your Lambda function that did not complete when the function ended resume if AWS Lambda chooses to reuse the execution context. You should make sure any background processes or callbacks in your code are complete before the code exits.
When you write your Lambda function code, do not assume that AWS Lambda automatically reuses the execution context for subsequent function invocations. Other factors may dictate a need for AWS Lambda to create a new execution context, which can lead to unexpected results, such as database connection failures.
Additionally for Node.js Lambda functions using non-async handlers:
For non-async handlers, function execution continues until the event loop is empty or the function times out. The response isn't sent to the invoker until all event loop tasks are finished. If the function times out, an error is returned instead. You can configure the runtime to send the response immediately by setting
context.callbackWaitsForEmptyEventLoop
to false.
Using only AWS Lambda, it is not possible.
You may want to look into AWS Step Functions in order to solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With