temporalio / sdk-go

Temporal Go SDK
https://docs.temporal.io/application-development?lang=go
MIT License
481 stars 197 forks source link

Workflow outcome is inconsistent between test env and real server #1496

Open bergundy opened 1 month ago

bergundy commented 1 month ago

When running a workflow that starts a child and cancels it:

wf := func(ctx workflow.Context) error {
    childCtx, cancel := workflow.WithCancel(ctx)
    defer cancel()
    fut := workflow.ExecuteChildWorkflow(childCtx, waitForCancelWorkflow)
    if err := fut.GetChildWorkflowExecution().Get(ctx, nil); err != nil {
        return err
    }
    cancel()
    return fut.Get(ctx, nil)
}

func waitForCancelWorkflow(ctx workflow.Context) error {
    return workflow.Await(ctx, func() bool { return false })
}

I'm getting inconsistent outcomes:

With server:

workflow execution error (type: func1, workflowID: 1eb1f045-b804-429f-b99e-57e45023a6e8, runID: 4821bd7c-b9f6-4684-92be-ab7354eefc36): canceled

With test env:

workflow execution error (type: func1, workflowID: default-test-workflow-id, runID: default-test-run-id): child workflow execution error (type: waitForCancelWorkflow, workflowID: default-test-run-id_1, runID: default-test-run-id_1_RunID, initiatedEventID: 0, startedEventID: 0): canceled

The test env is consistent with the behavior of other SDKs, but it's likely too late to change the cancelation behavior with the real server for consistency. I propose we change the test env to be consistent with the "real" env.