diff --git a/internal/client.go b/internal/client.go index 2e6745cae..3afd2b63e 100644 --- a/internal/client.go +++ b/internal/client.go @@ -746,7 +746,7 @@ type ( // workflow completion callback. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation]. callbacks []*commonpb.Callback // links. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation]. - links []*commonpb.Link + links []*commonpb.Link } // WithStartWorkflowOperation is a type of operation that can be executed as part of a workflow start. @@ -1082,6 +1082,9 @@ func (op *UpdateWithStartWorkflowOperation) Get(ctx context.Context) (WorkflowUp case <-op.doneCh: return op.handle, op.err case <-ctx.Done(): + if !op.executed.Load() { + return nil, fmt.Errorf("operation was not executed: %v", ctx.Err()) + } return nil, ctx.Err() } } diff --git a/internal/internal_workflow_client_test.go b/internal/internal_workflow_client_test.go index df3b644fc..ebb0117c6 100644 --- a/internal/internal_workflow_client_test.go +++ b/internal/internal_workflow_client_test.go @@ -1027,6 +1027,35 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Retry() { s.NoError(err) } +func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_OperationNotExecuted() { + s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()). + Return(&workflowservice.StartWorkflowExecutionResponse{ + RunId: runID, + }, nil) + + updOp := NewUpdateWithStartWorkflowOperation( + UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }) + + ctxWithTimeout, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) + defer cancel() + + _, err := s.workflowClient.ExecuteWorkflow( + ctxWithTimeout, + StartWorkflowOptions{ + ID: workflowID, + TaskQueue: taskqueue, + // WithStartOperation is not specified! + }, workflowType, + ) + require.NoError(s.T(), err) + + _, err = updOp.Get(ctxWithTimeout) + require.EqualError(s.T(), err, "operation was not executed: context deadline exceeded") +} + func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Abort() { tests := []struct { name string