File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,8 +99,20 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
9999 if ( this . _previousTask . isFailed ) {
100100 // Raise the failure as an exception to the generator. The orchestrator can then either
101101 // handle the exception or allow it to fail the orchestration.
102- await this . _generator . throw ( this . _previousTask . _exception ) ;
103- } else if ( this . _previousTask . isComplete ) {
102+ const { done, value } = await this . _generator . throw ( this . _previousTask . _exception ) ;
103+ if ( done ) {
104+ throw new StopIterationError ( value ) ;
105+ }
106+ if ( ! ( value instanceof Task ) ) {
107+ throw new Error ( "The orchestrator generator yielded a non-Task object" ) ;
108+ }
109+ this . _previousTask = value ;
110+ // If the new task is already complete, fall through to the isComplete handler
111+ if ( ! this . _previousTask . isComplete ) {
112+ return ;
113+ }
114+ }
115+ if ( this . _previousTask . isComplete ) {
104116 while ( true ) {
105117 // Resume the generator. This will either return a Task or raise StopIteration if it's done.
106118 // @todo : Should we check for possible infinite loops here?
You can’t perform that action at this time.
0 commit comments