File tree Expand file tree Collapse file tree
packages/durabletask-js/src/worker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,7 +113,22 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
113113 if ( this . _previousTask . isFailed ) {
114114 // Raise the failure as an exception to the generator. The orchestrator can then either
115115 // handle the exception or allow it to fail the orchestration.
116- await this . _generator . throw ( this . _previousTask . _exception ) ;
116+ const throwResult = await this . _generator . throw ( this . _previousTask . _exception ) ;
117+
118+ // If the generator caught the exception and completed, signal completion
119+ if ( throwResult . done ) {
120+ throw new StopIterationError ( throwResult . value ) ;
121+ }
122+
123+ // If the generator yielded a new task after catching the exception
124+ if ( throwResult . value instanceof Task ) {
125+ this . _previousTask = throwResult . value ;
126+ // If the new task is already complete, continue processing
127+ if ( this . _previousTask . isComplete ) {
128+ await this . resume ( ) ;
129+ }
130+ return ;
131+ }
117132 } else if ( this . _previousTask . isComplete ) {
118133 while ( true ) {
119134 // Resume the generator. This will either return a Task or raise StopIteration if it's done.
You can’t perform that action at this time.
0 commit comments