# Callback for Workflow Run Timeout

**URL:** <https://community.temporal.io/t/callback-for-workflow-run-timeout/7302>\
**Category:** Community Support\
**Tags:** go-sdk, general-impl\
**Created:** [February 17, 2023, 4:32am UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302 "2023-02-17T04:32:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiaowei](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/xiaowei/32/3332_2.png) [@Xiaowei](https://community.temporal.io/u/Xiaowei)\
**Post date:** [February 17, 2023, 4:32am UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302/1 "2023-02-17T04:32:56Z")

</div>

Hi there,

I have an onboarding user workflow, and one of the steps is to wait for user verification by signal. I want to apply a workflow run timeout to the workflow, and I would like to perform some cleaning tasks on timeout.

```auto
workflowOptions := client.StartWorkflowOptions{
  WorkflowRunTimeout: time.Hours * 24 * 365 * 10
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
  // ...
}

```

Is there a way for me to provide a handler or callback function to the workflow run timeout? Thanks for your time and help.

Cheers,  
Xiaowei

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 17, 2023, 6:22pm UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302/2 "2023-02-17T18:22:03Z")

</div>

`WorkflowRunTimeout` by definition is a timeout that terminates workflow without giving it any chance to perform the cleanup. Don’t use run or execution timeouts for business-level timeouts. Use a workflow timer to code any application specific cancellation and cleanup logic.

---

<div class="post-metadata">

**Author:** ![Xiaowei](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/xiaowei/32/3332_2.png) [@Xiaowei](https://community.temporal.io/u/Xiaowei)\
**Post date:** [February 17, 2023, 6:31pm UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302/3 "2023-02-17T18:31:50Z")

</div>

> [@maxim](#):
>
> workflow timer

Thanks for the suggestion!

---

<div class="post-metadata">

**Author:** ![cec](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/cec/32/6451_2.png) [@cec](https://community.temporal.io/u/cec)\
**Post date:** [January 10, 2025, 3:49pm UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302/4 "2025-01-10T15:49:05Z")

</div>

could you elaborate a bit more on how to do this in the java-sdk?  
I’m unable to find a workflow timer concept in the docs.

Cheers,  
cec

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [January 10, 2025, 5:55pm UTC](https://community.temporal.io/t/callback-for-workflow-run-timeout/7302/5 "2025-01-10T17:55:32Z")

</div>

Use `Workflow.sleep` and `Workflow.newTimer`. It is also helpful to understand [CancellationScope](https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/workflow/CancellationScope.java).
