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

asked 5 years ago3723 views
2 Answers
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
answered 5 years ago
  • 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!

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions