@@ -25,7 +25,7 @@ export class Orchestrator {
25
25
private newGuidCounter : number ;
26
26
private subOrchestratorCounter : number ;
27
27
28
- constructor ( public fn : ( context : IOrchestrationFunctionContext ) => IterableIterator < unknown > ) { }
28
+ constructor ( public fn : ( context : IOrchestrationFunctionContext ) => Generator < unknown , unknown , any > ) { }
29
29
30
30
public listen ( ) {
31
31
return this . handle . bind ( this ) ;
@@ -87,7 +87,7 @@ export class Orchestrator {
87
87
88
88
try {
89
89
// First execution, we have not yet "yielded" any of the tasks.
90
- let g = gen . next ( undefined ) ;
90
+ let g = gen . next ( ) ;
91
91
92
92
while ( true ) {
93
93
@@ -146,6 +146,13 @@ export class Orchestrator {
146
146
return ;
147
147
}
148
148
149
+ // The first time a task is marked as complete, the history event that finally marked the task as completed
150
+ // should not yet have been played by the Durable Task framework, resulting in isReplaying being false.
151
+ // On replays, the event will have already been processed by the framework, and IsPlayed will be marked as true.
152
+ if ( state [ partialResult . completionIndex ] !== undefined ) {
153
+ context . df . isReplaying = state [ partialResult . completionIndex ] . IsPlayed ;
154
+ }
155
+
149
156
if ( TaskFilter . isFailedTask ( partialResult ) ) {
150
157
if ( ! gen . throw ) {
151
158
throw new Error ( "Cannot properly throw the execption returned by customer code" ) ;
@@ -544,11 +551,10 @@ export class Orchestrator {
544
551
}
545
552
546
553
private all ( state : HistoryEvent [ ] , tasks : TaskBase [ ] ) : TaskSet {
547
- let maxCompletionIndex : number | undefined = undefined ;
554
+ let maxCompletionIndex : number | undefined ;
548
555
const errors : Error [ ] = [ ] ;
549
- const results : unknown [ ] = [ ] ;
550
- for ( let index = 0 ; index < tasks . length ; index ++ ) {
551
- const task = tasks [ index ] ;
556
+ const results : Array < unknown > = [ ] ;
557
+ for ( const task of tasks ) {
552
558
if ( ! TaskFilter . isCompletedTask ( task ) ) {
553
559
return TaskFactory . UncompletedTaskSet ( tasks ) ;
554
560
}
@@ -582,9 +588,8 @@ export class Orchestrator {
582
588
throw new Error ( "At least one yieldable task must be provided to wait for." ) ;
583
589
}
584
590
585
- let firstCompleted : CompletedTask | undefined = undefined ;
586
- for ( let index = 0 ; index < tasks . length ; index ++ ) {
587
- const task = tasks [ index ] ;
591
+ let firstCompleted : CompletedTask | undefined ;
592
+ for ( const task of tasks ) {
588
593
if ( TaskFilter . isCompletedTask ( task ) ) {
589
594
if ( ! firstCompleted ) {
590
595
firstCompleted = task ;
0 commit comments