@@ -752,9 +752,9 @@ func (s *Scheduler) Start(ctx context.Context, tasks ...*workflow.Task) error {
752752
753753 // We set markPending *after* enqueueTasks to give tasks an opportunity to
754754 // immediately transition into running (lowering state transition noise).
755- err = s .enqueueTasks (trackedTasks )
755+ s .enqueueTasks (trackedTasks )
756756 s .markPending (ctx , trackedTasks )
757- return err
757+ return nil
758758}
759759
760760// findTasks gets a list of [task] from workflow tasks. Returns an error if any
@@ -781,17 +781,15 @@ func (s *Scheduler) findTasks(tasks []*workflow.Task) ([]*task, error) {
781781 return res , nil
782782}
783783
784- func (s * Scheduler ) enqueueTasks (tasks []* task ) error {
784+ func (s * Scheduler ) enqueueTasks (tasks []* task ) {
785785 s .assignMut .Lock ()
786786 defer s .assignMut .Unlock ()
787787
788- var errs []error
789-
790788 for _ , task := range tasks {
791- // Only allow to enqueue tasks in the initial state (created). This
792- // prevents tasks from accidentally being run multiple times.
789+ // Ignore tasks that aren't in the initial state (created). This
790+ // prevents us from rejecting tasks which were preemptively canceled by
791+ // callers.
793792 if got , want := task .status .State , workflow .TaskStateCreated ; got != want {
794- errs = append (errs , fmt .Errorf ("task %s is in state %s, not %s" , task .inner .ULID , got , want ))
795793 continue
796794 }
797795
@@ -802,11 +800,6 @@ func (s *Scheduler) enqueueTasks(tasks []*task) error {
802800 if len (s .readyWorkers ) > 0 && len (s .taskQueue ) > 0 {
803801 nudgeSemaphore (s .assignSema )
804802 }
805-
806- if len (errs ) > 0 {
807- return errors .Join (errs ... )
808- }
809- return nil
810803}
811804
812805func (s * Scheduler ) markPending (ctx context.Context , tasks []* task ) {
0 commit comments