Lambda continues to run after ApiGateway request timed out

0

I set up an API Gateway endpoint, Lambda integration, default timeout (29s).

The Lambda sleeps for 40 seconds, then logs.

We observe the following:

  • 29 seconds after issuing the request, we receive {"message": "Endpoint request timed out"}
  • 40 seconds in, the Lambda logs

Why does the Lambda continue to run AFTER the request timed out? Currently, we rely on this behaviour - is it safe to assume things will stay this way, or could this change?

Edited by: mjfroehlich on Apr 26, 2019 5:32 AM

已提问 5 年前3798 查看次数
2 回答
1

Timeout happens in the API Gateway side, so Lambda will continue to execute your function. This is true for most HTTP client-server scenario. The client-side timeout does not guarantee to abort the execution in the server.

If you don't need to wait/return Lambda's response via API Gateway, then why don't you invoke it asynchronously?
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html

AWS
已回答 5 年前
  • My Nodejs lambda function stalled on timeout. I have a Nodejs lambda function with a 60sec timeout. When the API timeout happens on the 29th sec my lambda function stalls and gets timed out after 60 seconds. It is not continuing execution as you said

0

Nice, thanks for the pointer!

已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则