Skip to content

Commit a394dee

Browse files
Copilotcschleiden
andcommitted
Add support for EventType_WorkflowExecutionContinuedAsNew in executor and unit test
Co-authored-by: cschleiden <[email protected]>
1 parent cfcf12a commit a394dee

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

workflow/executor/executor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ func (e *executor) executeEvent(event *history.Event) error {
365365
case history.EventType_WorkflowExecutionFinished:
366366
// Ignore
367367

368+
case history.EventType_WorkflowExecutionContinuedAsNew:
369+
// Ignore
370+
368371
case history.EventType_WorkflowExecutionCanceled:
369372
err = e.handleWorkflowCanceled()
370373

workflow/executor/executor_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,50 @@ func Test_Executor(t *testing.T) {
707707
require.Equal(t, goRoutines, runtime.NumGoroutine())
708708
},
709709
},
710+
{
711+
name: "WorkflowExecutionContinuedAsNew event handled without error",
712+
f: func(t *testing.T, r *registry.Registry, e *executor, i *core.WorkflowInstance, hp *testHistoryProvider) {
713+
// Simple workflow that completes
714+
wf := func(ctx sync.Context) error {
715+
return nil
716+
}
717+
718+
r.RegisterWorkflow(wf)
719+
720+
// Create a task with WorkflowExecutionContinuedAsNew event
721+
result, _ := converter.DefaultConverter.To(42)
722+
task := &backend.WorkflowTask{
723+
ID: "taskID",
724+
WorkflowInstance: core.NewWorkflowInstance("instanceID", "executionID"),
725+
Metadata: &metadata.WorkflowMetadata{},
726+
NewEvents: []*history.Event{
727+
history.NewHistoryEvent(
728+
1,
729+
time.Now(),
730+
history.EventType_WorkflowExecutionStarted,
731+
&history.ExecutionStartedAttributes{
732+
Name: fn.Name(wf),
733+
Inputs: []payload.Payload{},
734+
},
735+
),
736+
history.NewHistoryEvent(
737+
2,
738+
time.Now(),
739+
history.EventType_WorkflowExecutionContinuedAsNew,
740+
&history.ExecutionContinuedAsNewAttributes{
741+
Result: result,
742+
ContinuedExecutionID: "continued-execution-id",
743+
},
744+
),
745+
},
746+
}
747+
748+
// Execute the task - should not return an error
749+
_, err := e.ExecuteTask(context.Background(), task)
750+
require.NoError(t, err)
751+
require.Nil(t, e.workflow.err)
752+
},
753+
},
710754
}
711755

712756
for _, tt := range tests {

0 commit comments

Comments
 (0)