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

gefragt vor 5 Jahren3798 Aufrufe
2 Antworten
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
beantwortet vor 5 Jahren
  • 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!

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen