CodexBloom - Programming Q&A Platform

AWS Step Functions scenarios with 'Task timed out after 60 seconds' When Invoking Lambda with Large Payloads

πŸ‘€ Views: 84 πŸ’¬ Answers: 1 πŸ“… Created: 2025-07-23
aws lambda step-functions timeout serverless Python

I'm reviewing some code and I'm prototyping a solution and I'm sure I'm missing something obvious here, but I'm currently working on AWS Step Functions where I need to invoke a Lambda function that processes a large dataset... However, I'm working with the behavior message 'Task timed out after 60 seconds'. I've set up my Step Function to use a Lambda state that should trigger a processing function, but it seems to time out even when I know the function can handle the workload. Here's the relevant part of my Step Function definition: ```json { "Comment": "A simple AWS Step Functions state machine that invokes a Lambda function.", "StartAt": "ProcessData", "States": { "ProcessData": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:ProcessLargeData", "TimeoutSeconds": 300, "End": true } } } ``` Even though I've specified a `TimeoutSeconds` of 300 seconds for the Step Function, the Lambda function itself is configured with a timeout of 60 seconds. I think that might be affecting the whole process, but I'm not sure how to adjust it properly. I've tried increasing the Lambda timeout in the AWS Management Console, but every time I deploy, it seems to revert back to 60 seconds. My Lambda function code is written in Python using Boto3, and here’s a snippet of how I'm processing the data: ```python import json def lambda_handler(event, context): # Simulate processing a large dataset data = event.get('data') result = process_heavy_task(data) return { 'statusCode': 200, 'body': json.dumps(result) } def process_heavy_task(data): # Simulated long-running task import time time.sleep(70) # Simulate processing time longer than 60 seconds return "Processing Complete" ``` Also, when I test the function independently with smaller payloads, it works perfectly fine. However, with larger payloads, it exceeds the timeout limit even though the Step Function has a longer timeout. Am I missing something here? How can I ensure that my Lambda function can handle larger payloads without timing out, and how should I configure the timeouts correctly to prevent this scenario? For context: I'm using Python on Linux. Am I missing something obvious? My team is using Python for this web app. I'm working on a mobile app that needs to handle this. This is my first time working with Python 3.10. Could someone point me to the right documentation?