# Error in workflow after a long await

**URL:** <https://community.temporal.io/t/error-in-workflow-after-a-long-await/1371>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [January 25, 2021, 3:39am UTC](https://community.temporal.io/t/error-in-workflow-after-a-long-await/1371 "2021-01-25T03:39:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jayanth\_Tatina](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jayanth_tatina/32/650_2.png) [@Jayanth\_Tatina](https://community.temporal.io/u/Jayanth_Tatina)\
**Post date:** [January 25, 2021, 3:39am UTC](https://community.temporal.io/t/error-in-workflow-after-a-long-await/1371/1 "2021-01-25T03:39:35Z")

</div>

Hi,

I have a workflow set up running with a while true loop within it having 4 activities and an await() state.  
if the await state is small like around 5 min, the workflow is executed properly every 5 min .

But when the await() is longer like 15hr after some time like 10hr below error is thrown in the slacktrace

1. What are the possible scenarios that this error can be thrown
2. If anyone else faced with this error, how is this resolved

`3 INVALID_ARGUMENT: io.temporal.internal.replay.InternalWorkflowTaskException: Failure handling event 28 of 'EVENT_TYPE_TIMER_STARTED' type. IsReplaying=true, PreviousStartedEventId=26, workflowTaskStartedEventId=0, Currently Processing StartedEventId=26 at io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:193) at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleEvent(ReplayWorkflowRunTaskHandler.java:140) at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleWorkflowTaskImpl(ReplayWorkflowRunTaskHandler.java:180) at io.temporal.internal.replay.ReplayWorkflowRunTaskHandler.handleQueryWorkflowTask(ReplayWorkflowRunTaskHandler.java:255) at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleQueryOnlyWorkflowTask(ReplayWorkflowTaskHandler.java:258) at io.temporal.internal.replay.ReplayWorkflowTaskHandler.handleWorkflowTask(ReplayWorkflowTaskHandler.java:112) at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:309) at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:275) at io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalStateException: Event 28 of EVENT_TYPE_TIMER_STARTED does not match command COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK at io.temporal.internal.statemachines.WorkflowStateMachines.handleCommandEvent(WorkflowStateMachines.java:263) at io.temporal.internal.statemachines.WorkflowStateMachines.handleEventImpl(WorkflowStateMachines.java:199) at io.temporal.internal.statemachines.WorkflowStateMachines.handleEvent(WorkflowStateMachines.java:178) ... 11 more`

---

<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 25, 2021, 3:41am UTC](https://community.temporal.io/t/error-in-workflow-after-a-long-await/1371/2 "2021-01-25T03:41:58Z")

</div>

What is the Java SDK version?  
Was the code updated during the 10 hour window?  
If you could share code and post the event history (or DM me directly) it would also help.

---

<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 25, 2021, 4:52pm UTC](https://community.temporal.io/t/error-in-workflow-after-a-long-await/1371/3 "2021-01-25T16:52:54Z")

</div>

The problem was in breaking determinism by using `DateUtils.getCurrTime()` which in turn called `LocalDateTime.now(zoneId)`.

According to [Workflow Implementation Constraints](https://docs.temporal.io/docs/java-implementing-workflows#workflow-implementation-constraints) only time returned by `Workflow.currentTimeMillis` can be used inside the workflow code.
