From 0a140780007ce99a8c8b289fe45790d6d31a78bd Mon Sep 17 00:00:00 2001 From: Karla Muller Date: Fri, 19 Sep 2025 15:13:53 -0700 Subject: [PATCH] Fix workflow:wait timeout to use warnings instead of errors --- src/Commands/Workflow/WaitCommand.php | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Commands/Workflow/WaitCommand.php b/src/Commands/Workflow/WaitCommand.php index b04fb4c02..821699c9c 100644 --- a/src/Commands/Workflow/WaitCommand.php +++ b/src/Commands/Workflow/WaitCommand.php @@ -111,18 +111,20 @@ protected function waitForWorkflow( do { $current_time = time(); if ($maxNotFoundAttempts && $not_found_attempts === $maxNotFoundAttempts) { - throw new TerminusException( + $this->log()->warning( "Attempted '{max}' times, giving up waiting for workflow to be found", ['max' => $maxNotFoundAttempts] ); + return; } - // Check if the timeout has been reached and throw an exception if so. + // Check if the timeout has been reached and log warning if so. if ($end_time > 0 && $current_time >= $end_time) { - throw new TerminusException( - 'Workflow timed out after {timeout} seconds.', + $this->log()->warning( + 'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish', ['timeout' => $maxWaitInSeconds] ); + return; } $site = $this->getSiteById($site->id); $workflows->reset(); @@ -171,10 +173,11 @@ protected function waitForWorkflow( } do { if ($end_time > 0 && $current_time >= $end_time) { - throw new TerminusException( - 'Workflow timed out after {timeout} seconds.', + $this->log()->warning( + 'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish', ['timeout' => $maxWaitInSeconds] ); + return; } $workflow->fetch(); usleep($retry_interval * 1000); @@ -226,10 +229,11 @@ protected function waitForCommit( // Check timeout if ($end_time > 0 && $current_time >= $end_time) { - throw new TerminusException( - 'Workflow with commit {commit} timed out after {timeout} seconds.', + $this->log()->warning( + 'Waited \'{timeout}\' seconds, giving up waiting for workflow with commit {commit} to finish', ['commit' => $target_commit, 'timeout' => $maxWaitInSeconds] ); + return; } // Fetch workflow logs using the logs/workflows endpoint @@ -281,10 +285,11 @@ protected function waitForCommit( $retry_count++; if ($retry_count >= $max_retries) { - throw new TerminusException( + $this->log()->warning( 'Workflow with commit {commit} not found after {retries} attempts.', ['commit' => $target_commit, 'retries' => $max_retries] ); + return; } $this->log()->debug('Workflow not found, retrying... ({retry}/{max})', [ @@ -305,10 +310,11 @@ protected function waitForCommit( do { $current_time = time(); if ($end_time > 0 && $current_time >= $end_time) { - throw new TerminusException( - 'Workflow timed out after {timeout} seconds.', + $this->log()->warning( + 'Waited \'{timeout}\' seconds, giving up waiting for workflow to finish', ['timeout' => $maxWaitInSeconds] ); + return; } // Re-fetch workflow logs to get updated status