diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5e48bf9e4..a8074d53e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -135,11 +135,6 @@ namespace]]> - - - getSuccess()]]> - - diff --git a/src/Client/Update/UpdateHandle.php b/src/Client/Update/UpdateHandle.php index f8f3de773..cf42a6306 100644 --- a/src/Client/Update/UpdateHandle.php +++ b/src/Client/Update/UpdateHandle.php @@ -114,22 +114,38 @@ private function fetchResult(int|float|null $timeout = null): void (new \Temporal\Api\Update\V1\WaitPolicy())->setLifecycleStage(LifecycleStage::StageCompleted->value), ); - try { - $response = $this->client->PollWorkflowExecutionUpdate( - $request, - $timeout === null ? null : $this->client->getContext()->withTimeout($timeout), - ); - } catch (TimeoutException|CanceledException $e) { - throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e); - } - // Workflow Uprate accepted - $result = $response->getOutcome(); - \assert($result !== null); + $context = $timeout === null + ? $this->client->getContext() + : $this->client->getContext()->withTimeout($timeout); + $deadline = $context->getDeadline(); + + // Convert request timeout into deadline + $deadline === null or $context = $context->withDeadline($deadline); + + do { + try { + $response = $this->client->PollWorkflowExecutionUpdate($request, $context); + } catch (TimeoutException|CanceledException $e) { + throw WorkflowUpdateRPCTimeoutOrCanceledException::fromTimeoutOrCanceledException($e); + } + + // Workflow Uprate accepted + $result = $response->getOutcome(); + + /** + * Retry the request. + * + * TimeoutException will be thrown in {@see \Temporal\Client\GRPC\BaseClient::call()} method + * because the deadline is provided in the context. + * That's why the deadline condition is not checked here. + */ + } while ($result === null); // Accepted with result - if ($result->getSuccess() !== null) { - $this->result = EncodedValues::fromPayloads($result->getSuccess(), $this->converter); + $success = $result->getSuccess(); + if ($success !== null) { + $this->result = EncodedValues::fromPayloads($success, $this->converter); return; } diff --git a/src/Exception/Failure/FailureConverter.php b/src/Exception/Failure/FailureConverter.php index 1d1d4262e..066b95529 100644 --- a/src/Exception/Failure/FailureConverter.php +++ b/src/Exception/Failure/FailureConverter.php @@ -11,7 +11,6 @@ namespace Temporal\Exception\Failure; -use Psr\Log\LoggerInterface; use Temporal\Api\Common\V1\ActivityType; use Temporal\Api\Common\V1\WorkflowExecution; use Temporal\Api\Common\V1\WorkflowType; @@ -30,8 +29,6 @@ final class FailureConverter { - private static ?LoggerInterface $logger; - public static function mapFailureToException(Failure $failure, DataConverterInterface $converter): TemporalFailure { $e = self::createFailureException($failure, $converter); @@ -160,11 +157,6 @@ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterfa return $failure; } - public function setLogger(LoggerInterface $logger): void - { - self::$logger = $logger; - } - private static function createFailureException(Failure $failure, DataConverterInterface $converter): TemporalFailure { $previous = null;