Skip to content

Lambda Function Behavior After Step Functions Task State Timeout

0

We are designing a Step Functions workflow that orchestrates multiple Lambda functions. I want to understand the timeout interaction between Step Functions Task states and Lambda function timeouts. Specifically, if a Lambda function has a 15-minute timeout configured and the Step Functions Task state has a TimeoutSeconds of 300 (5 minutes), what happens when the Task state times out while the Lambda function is still executing? Does the Lambda function continue running in the background until it completes or reaches its own 15-minute timeout, or does Step Functions terminate the Lambda execution when the Task state times out?

1 Answer
1
Accepted Answer

When a Step Functions Task state times out while invoking a Lambda function, the Lambda function continues to run in the background until it either completes or reaches its own configured timeout limit. Step Functions does not have the ability to terminate or stop the Lambda function execution when the Task state timeout is reached.

Here's what happens in your specific scenario:

  1. The Step Functions Task state will wait for up to 5 minutes (300 seconds as specified by TimeoutSeconds) for the Lambda function to complete
  2. If the Lambda function doesn't respond within those 5 minutes, Step Functions will mark the Task state as failed with a States.Timeout error
  3. The Lambda function will continue executing independently until it either:
  • Completes its work (up to the 15-minute Lambda timeout)
  • Reaches its own 15-minute timeout and is terminated by Lambda itself

This means the Lambda function becomes "orphaned" from the Step Functions workflow perspective. The workflow will have already moved on (either to an error handler, retry logic, or marked as failed), while the Lambda function continues processing in the background.

To handle this scenario effectively, you should:

  • Set the Task state TimeoutSeconds to be less than or equal to your Lambda function timeout to avoid unnecessary waiting
  • Implement proper error handling using Retry and Catch fields in your Task state definition
  • Consider implementing idempotency in your Lambda functions to handle potential retry scenarios
  • Be aware that you'll be charged for the full Lambda execution time, even after the Step Functions Task state has timed out
    Sources
    Handling errors in Step Functions workflows - AWS Step Functions
    Task workflow state - AWS Step Functions
answered a month ago
EXPERT
reviewed a month 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.