@@ -839,14 +839,11 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
839839 return earlyReturnPollingHandle , nil
840840 }
841841
842- outcomeChan := make (chan workflowOutcome [any ], 1 )
843-
844842 // Create workflow state to track step execution
845843 wfState := & workflowState {
846844 workflowID : workflowID ,
847845 stepID : - 1 , // Steps are O-indexed
848846 }
849-
850847 workflowCtx := WithValue (c , workflowStateKey , wfState )
851848
852849 // If the workflow has a timeout but no deadline, compute the deadline from the timeout.
@@ -863,7 +860,7 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
863860 if ! durableDeadline .IsZero () {
864861 workflowCtx , _ = WithTimeout (workflowCtx , time .Until (durableDeadline ))
865862 // Register a cancel function that cancels the workflow in the DB as soon as the context is cancelled
866- dbosCancelFunction := func () {
863+ workflowCancelFunction := func () {
867864 c .logger .Info ("Cancelling workflow" , "workflow_id" , workflowID )
868865 err = retry (c , func () error {
869866 return c .systemDB .cancelWorkflow (uncancellableCtx , workflowID )
@@ -873,10 +870,11 @@ func (c *dbosContext) RunWorkflow(_ DBOSContext, fn WorkflowFunc, input any, opt
873870 }
874871 close (cancelFuncCompleted )
875872 }
876- stopFunc = context .AfterFunc (workflowCtx , dbosCancelFunction )
873+ stopFunc = context .AfterFunc (workflowCtx , workflowCancelFunction )
877874 }
878875
879876 // Run the function in a goroutine
877+ outcomeChan := make (chan workflowOutcome [any ], 1 )
880878 c .workflowsWg .Add (1 )
881879 go func () {
882880 defer c .workflowsWg .Done ()
0 commit comments