I have an API lambda that is invoked from an API Gateway. Some of the routes execute heavy queries and I noticed that when I cancel the API call from the frontend, the lambda is continuing the invocation.
The lambda is implemented in Go, and I tried to use the context I got from the lambda handler function to stop the DB query, but it finished the invocation as if nothing had happened.
With a basic AWS Lambda, there is no interruption except for a timeout. When you examine the Lambda runtime API, you'll see that it gets the next request from the .../next
endpoint and posts the result to the .../response
(or .../error
) endpoint, there is no communication in between.
You could write an extension, but it might be simpler to break down the heavy queries into smaller parts and use something like Step Functions, which has StopExecution
.