@@ -1440,7 +1440,6 @@ func (s *sysDB) getWorkflowSteps(ctx context.Context, workflowID string) ([]Step
14401440
14411441type sleepInput struct {
14421442 duration time.Duration // Duration to sleep
1443- stepID int // Optional step ID to use (if < 0, a new step ID will be assigned)
14441443 skipSleep bool // If true, the function will not actually sleep (useful for testing)
14451444}
14461445
@@ -1462,14 +1461,12 @@ func (s *sysDB) sleep(ctx context.Context, input sleepInput) (time.Duration, err
14621461 return 0 , newStepExecutionError (wfState .workflowID , functionName , "cannot call Sleep within a step" )
14631462 }
14641463
1465- if input .stepID < 0 {
1466- input .stepID = wfState .NextStepID ()
1467- }
1464+ stepID := wfState .NextStepID ()
14681465
14691466 // Check if operation was already executed
14701467 checkInput := checkOperationExecutionDBInput {
14711468 workflowID : wfState .workflowID ,
1472- stepID : input . stepID ,
1469+ stepID : stepID ,
14731470 stepName : functionName ,
14741471 }
14751472 recordedResult , err := s .checkOperationExecution (ctx , checkInput )
@@ -1496,14 +1493,14 @@ func (s *sysDB) sleep(ctx context.Context, input sleepInput) (time.Duration, err
14961493 }
14971494 } else {
14981495 // First execution: calculate and record the end time
1499- s .logger .Debug ("Durable sleep" , "stepID" , input . stepID , "duration" , input .duration )
1496+ s .logger .Debug ("Durable sleep" , "stepID" , stepID , "duration" , input .duration )
15001497
15011498 endTime = time .Now ().Add (input .duration )
15021499
15031500 // Record the operation result with the calculated end time
15041501 recordInput := recordOperationResultDBInput {
15051502 workflowID : wfState .workflowID ,
1506- stepID : input . stepID ,
1503+ stepID : stepID ,
15071504 stepName : functionName ,
15081505 output : endTime ,
15091506 err : nil ,
@@ -1764,7 +1761,6 @@ func (s *sysDB) recv(ctx context.Context, input recvInput) (any, error) {
17641761
17651762 timeout , err := s .sleep (ctx , sleepInput {
17661763 duration : input .Timeout ,
1767- stepID : wfState .NextStepID (),
17681764 skipSleep : true ,
17691765 })
17701766 if err != nil {
@@ -1994,7 +1990,6 @@ func (s *sysDB) getEvent(ctx context.Context, input getEventInput) (any, error)
19941990 if isInWorkflow {
19951991 timeout , err = s .sleep (ctx , sleepInput {
19961992 duration : input .Timeout ,
1997- stepID : wfState .NextStepID (),
19981993 skipSleep : true ,
19991994 })
20001995 if err != nil {
0 commit comments