#18221: fix(cli): raise cron command timeout to 90s and retry read-only RPCs
channel: mattermost
cli
size: M
Cluster:
Cron Job Stability Fixes
## Summary
- Add optional `{ defaultTimeoutMs }` parameter to `addGatewayClientOptions` so per-command defaults can override the global 30s timeout without affecting other CLI surfaces.
- Apply 90s default to all cron CLI registrations (status, list, add, edit, rm, enable, disable, runs, run).
- Retry once (after 250ms) for idempotent read-only cron methods (`cron.status`, `cron.list`, `cron.runs`) when the error is a gateway timeout.
Closes #18118
## Test plan
- [x] New `gateway-rpc.test.ts` with 6 tests: retry on timeout for each read-only method, no retry for non-cron/mutating/non-timeout errors
- [x] New test in `cron-cli.test.ts` verifying 90s default timeout is passed through
- [x] All 22 existing + new cron CLI tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a per-command `defaultTimeoutMs` option to `addGatewayClientOptions` and applies a 90s timeout default to all cron CLI commands (status, list, add, edit, rm, enable, disable, runs, run). Also implements retry logic for read-only cron methods (`cron.status`, `cron.list`, `cron.runs`) that automatically retries once after 250ms when a gateway timeout occurs. The implementation correctly scopes retries to only idempotent read operations and excludes mutating commands like `cron.add` or `cron.remove`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-tested with comprehensive unit tests covering all retry scenarios (positive and negative cases). The implementation is clean and scoped - only affecting cron CLI commands with increased timeout and retry only on idempotent read operations. Test coverage includes verification that non-retryable methods don't retry, and that only timeout errors trigger retries.
- No files require special attention
<sub>Last reviewed commit: ee2abb7</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#13055: fix: prevent cron RPC stalls with timeout and caching (#13018)
by trevorgordon981 · 2026-02-10
79.4%
#7615: fix(gateway): add request timeout to GatewayClient
by alamine42 · 2026-02-03
79.1%
#11857: fix: recompute stale cron nextRunAtMs on gateway restart
by Yida-Dev · 2026-02-08
75.8%
#20329: Fix cron.run WS blocking and harden delivery recovery
by guirguispierre · 2026-02-18
75.3%
#18144: fix(cron): clear stuck runningAtMs after timeout and add maintenanc...
by taw0002 · 2026-02-16
75.3%
#8698: fix(cron): default enabled to true for new jobs
by emmick4 · 2026-02-04
75.0%
#6302: fix: Add timeouts to prevent indefinite hangs (issues #4954, #4956,...
by batumilove · 2026-02-01
75.0%
#11522: Fix #10904: Add hard timeout to lane tasks to prevent cron wedging
by divol89 · 2026-02-07
74.5%
#6515: fix: in-process IPC for cron tool to avoid WS self-contention timeout
by amco3008 · 2026-02-01
73.6%
#22411: fix(cron): cancel timed-out runs before side effects
by Takhoffman · 2026-02-21
73.3%