Skip to content

Commit

Permalink
Fix coroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Dec 16, 2024
1 parent f533a99 commit e82da4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Internal/Workflow/Process/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ function () use ($cancelID): void {
*/
protected function call(\Closure $handler, ValuesInterface $values): DeferredGenerator
{
return DeferredGenerator::fromHandler($handler, $values)->catch($this->onException(...));
$generator = DeferredGenerator::fromHandler($handler, $values)
->catch(tr(...))
->catch($this->onException(...));
// Run lazy generator
$generator->current();
return $generator;
}

/**
Expand Down Expand Up @@ -397,7 +402,11 @@ protected function next(): void
$this->context->resolveConditions();

if (!$this->coroutine->valid()) {
$this->onResult($this->coroutine->getReturn());
try {
$this->onResult($this->coroutine->getReturn());
} catch (\Throwable) {
$this->onResult(null);
}

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ChildWorkflow
#[WorkflowMethod('Harness_ChildWorkflow_ThrowsOnExecute_Child')]
public function run()
{
yield 1;
throw new ApplicationFailure('Test message', 'TestError', true, EncodedValues::fromValues([['foo' => 'bar']]));
}
}

0 comments on commit e82da4c

Please sign in to comment.