Skip to content

Commit 81da60f

Browse files
committed
fix(workflow:watch): increase poll interval to 10s and add 30min default timeout
- Increase WORKFLOWS_WATCH_INTERVAL from 5s to 10s to reduce API call rate - Add WORKFLOWS_WATCH_MAX_CHECKS = 180 (30 min at 10s/poll) as default --checks - Replace null/infinite default with bounded default; pass --checks=0 for no limit - Emit a warning when the timeout is reached so users know why the command exited - Update docblock and CHANGELOG Prevents runaway API call volumes when workflow:watch is left running unattended in CI/CD pipelines with no --checks limit.
1 parent 6e64d59 commit 81da60f

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org)
33

4+
## [Unreleased]
5+
6+
### Changed
7+
8+
- `workflow:watch` poll interval increased from 5s to 10s to reduce API call volume (#)
9+
- `workflow:watch` now times out after 180 checks (~30 minutes) by default instead of running indefinitely; pass `--checks=0` for the previous unlimited behavior (#)
10+
411
## 4.2.0-rc.1 - 2026-03-18
512

613
### Added

src/Commands/Workflow/WatchCommand.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class WatchCommand extends TerminusCommand implements SiteAwareInterface
1515
{
1616
use SiteAwareTrait;
1717

18-
public const WORKFLOWS_WATCH_INTERVAL = 5;
18+
public const WORKFLOWS_WATCH_INTERVAL = 10;
19+
public const WORKFLOWS_WATCH_MAX_CHECKS = 180;
1920
/**
2021
* @var array We keep track of workflows that have been printed. This is necessary because the local clock may
2122
* drift from the server's clock, causing events to be printed twice.
@@ -34,7 +35,7 @@ class WatchCommand extends TerminusCommand implements SiteAwareInterface
3435
*
3536
* @command workflow:watch
3637
*
37-
* @option integer $checks Times to query
38+
* @option integer $checks Times to query (default: 180, ~30 minutes at 10s interval). Pass 0 for no limit.
3839
*
3940
* @usage <site> Streams new and finished workflows from <site> to the console.
4041
*
@@ -46,12 +47,10 @@ class WatchCommand extends TerminusCommand implements SiteAwareInterface
4647
* @throws \Psr\Container\ContainerExceptionInterface
4748
* @throws \Psr\Container\NotFoundExceptionInterface
4849
*/
49-
public function watch($site_id, $options = ['checks' => null])
50+
public function watch($site_id, $options = ['checks' => self::WORKFLOWS_WATCH_MAX_CHECKS])
5051
{
5152
$site = $this->getSiteById($site_id);
52-
if (!is_null($number_of_checks = $options['checks'])) {
53-
$number_of_checks = (int)$number_of_checks;
54-
}
53+
$number_of_checks = (int)$options['checks'];
5554

5655
$this->log()->notice('Watching workflows...');
5756
$site->getWorkflows()->fetchWithOperations();
@@ -80,7 +79,11 @@ public function watch($site_id, $options = ['checks' => null])
8079
}
8180
}
8281
}
83-
if (!is_null($number_of_checks) && (--$number_of_checks < 1)) {
82+
if ($number_of_checks > 0 && (--$number_of_checks < 1)) {
83+
$this->log()->warning(
84+
'Workflow watch timed out after {checks} checks. Use --checks=0 for no limit.',
85+
['checks' => self::WORKFLOWS_WATCH_MAX_CHECKS]
86+
);
8487
break;
8588
}
8689
}

0 commit comments

Comments
 (0)