# State machine calls a lambda but lambda times out (when I understand there shouldn't be one)

**URL:** https://forum.serverless.com/t/state-machine-calls-a-lambda-but-lambda-times-out-when-i-understand-there-shouldnt-be-one/15498
**Category:** Serverless Framework
**Tags:** long-running-process
**Created:** [July 5, 2021, 9:26pm UTC](https://forum.serverless.com/t/state-machine-calls-a-lambda-but-lambda-times-out-when-i-understand-there-shouldnt-be-one/15498 "2021-07-05T21:26:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ryantomaselli](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ryantomaselli/32/5180_2.png) [@ryantomaselli](https://forum.serverless.com/u/ryantomaselli)
#### Post date: [July 5, 2021, 9:26pm UTC](https://forum.serverless.com/t/state-machine-calls-a-lambda-but-lambda-times-out-when-i-understand-there-shouldnt-be-one/15498/1 "2021-07-05T21:26:06Z")

</div>

Hey guys;

I have a process that can take some time and I don’t want things to time out in an uncontrolled fashion…so I reached for a step function.

I declared a state machine with a single task that references a Lambda hoping my Lambda could happily churn away until completion (and I would set a TimeoutSeconds just in case things got ridiculous).

But no, vision and reality conflict. The reality is the lambda function times out (after the default timeout of 6 seconds). I don’t want a timeout on the Lambda itself.

The error displayed when I click on the failed step in the AWS console is like so:  
"The cause could not be determined because Lambda did not return an error type. Returned payload: {“errorMessage”:“2021-07-05T21:01:14.951Z f2fd7db1-33ca-4a8c-a7fe-b6fcf8a167b9 Task timed out after 6.01 seconds”}

I am starting the state machine in a API Gateway Lambda trigger using AWS.StepFunctions().startExecution.

How do I hook things up so the Lambda does not time out? Do I need to send a heartbeat?

Any pointers greatly appreciated…I feel stumped on this.

Cheers

---

<div class="post-metadata">

### Author: ![bfieber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bfieber/32/653_2.png) [@bfieber](https://forum.serverless.com/u/bfieber)
#### Post date: [July 6, 2021, 3:42pm UTC](https://forum.serverless.com/t/state-machine-calls-a-lambda-but-lambda-times-out-when-i-understand-there-shouldnt-be-one/15498/2 "2021-07-06T15:42:12Z")

</div>

StepFunctions Can run up to 1 year.  
But the individual Lambda functions still have the same limitations they have when used outside of a StepFunction. So you can set a timeout on your individual Lambda functions of up to 15 minutes, but not remove it completely.

That being said, if you have a single process that needs to run longer, you need to break it up in smaller pieces that can fit without the 15 minute max timeout.

---

<div class="post-metadata">

### Author: ![ryantomaselli](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ryantomaselli/32/5180_2.png) [@ryantomaselli](https://forum.serverless.com/u/ryantomaselli)
#### Post date: [July 6, 2021, 4:00pm UTC](https://forum.serverless.com/t/state-machine-calls-a-lambda-but-lambda-times-out-when-i-understand-there-shouldnt-be-one/15498/3 "2021-07-06T16:00:45Z")

</div>

Thanks for that clarification Brett!
