6
6
"fmt"
7
7
"log/slog"
8
8
"reflect"
9
+ "slices"
9
10
10
11
"github.com/benbjohnson/clock"
11
12
"github.com/cschleiden/go-workflows/backend"
@@ -264,8 +265,15 @@ func (e *executor) executeNewEvents(newEvents []*history.Event) ([]*history.Even
264
265
if e .workflow .Completed () {
265
266
// TODO: Is this too early? We haven't committed some of the commands
266
267
if e .workflowState .HasPendingFutures () {
267
- e .logger .Error ("workflow completed, but there are still pending futures" )
268
- panic ("workflow completed, but there are still pending futures" )
268
+ var pending []string
269
+ pf := e .workflowState .PendingFutureNames ()
270
+ for id , name := range pf {
271
+ pending = append (pending , fmt .Sprintf ("%d-%s" , id , name ))
272
+ }
273
+ slices .Sort (pending )
274
+
275
+ e .logger .Error ("workflow completed, but there are still pending futures" , "pending" , pending )
276
+ panic (fmt .Sprintf ("workflow completed, but there are still pending futures: %s" , pending ))
269
277
}
270
278
271
279
if canErr , ok := e .workflow .Error ().(* continueasnew.Error ); ok {
@@ -411,7 +419,7 @@ func (e *executor) handleActivityCompleted(event *history.Event, a *history.Acti
411
419
return fmt .Errorf ("could not find pending future for activity completion" )
412
420
}
413
421
414
- err := f (a .Result , nil )
422
+ err := f . Set (a .Result , nil )
415
423
if err != nil {
416
424
return fmt .Errorf ("setting activity completed result: %w" , err )
417
425
}
@@ -440,7 +448,7 @@ func (e *executor) handleActivityFailed(event *history.Event, a *history.Activit
440
448
}
441
449
442
450
actErr := workflowerrors .ToError (a .Error )
443
- if err := f (nil , actErr ); err != nil {
451
+ if err := f . Set (nil , actErr ); err != nil {
444
452
return fmt .Errorf ("setting activity failed result: %w" , err )
445
453
}
446
454
@@ -483,7 +491,7 @@ func (e *executor) handleTimerFired(event *history.Event, a *history.TimerFiredA
483
491
return nil
484
492
}
485
493
486
- if err := f (nil , nil ); err != nil {
494
+ if err := f . Set (nil , nil ); err != nil {
487
495
return fmt .Errorf ("setting timer fired result: %w" , err )
488
496
}
489
497
@@ -523,7 +531,7 @@ func (e *executor) handleTimerCanceled(event *history.Event, a *history.TimerCan
523
531
return nil
524
532
}
525
533
526
- if err := f (nil , sync .Canceled ); err != nil {
534
+ if err := f . Set (nil , sync .Canceled ); err != nil {
527
535
return fmt .Errorf ("setting timer canceled result: %w" , err )
528
536
}
529
537
@@ -580,7 +588,7 @@ func (e *executor) handleSubWorkflowFailed(event *history.Event, a *history.SubW
580
588
581
589
wfErr := workflowerrors .ToError (a .Error )
582
590
583
- if err := f (nil , wfErr ); err != nil {
591
+ if err := f . Set (nil , wfErr ); err != nil {
584
592
return fmt .Errorf ("setting sub workflow failed result: %w" , err )
585
593
}
586
594
@@ -606,7 +614,7 @@ func (e *executor) handleSubWorkflowCompleted(event *history.Event, a *history.S
606
614
return errors .New ("no pending future found for sub workflow completed event" )
607
615
}
608
616
609
- if err := f (a .Result , nil ); err != nil {
617
+ if err := f . Set (a .Result , nil ); err != nil {
610
618
return fmt .Errorf ("setting sub workflow completed result: %w" , err )
611
619
}
612
620
@@ -651,7 +659,7 @@ func (e *executor) handleSideEffectResult(event *history.Event, a *history.SideE
651
659
return errors .New ("no pending future found for side effect result event" )
652
660
}
653
661
654
- if err := f (a .Result , nil ); err != nil {
662
+ if err := f . Set (a .Result , nil ); err != nil {
655
663
return fmt .Errorf ("setting side effect result result: %w" , err )
656
664
}
657
665
0 commit comments