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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南