Add TRUNK_API_CLIENT_RETRY_DEADLINE_SECS to bound API retry time#1131
Merged
Conversation
|
😎 Merged successfully - details. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1131 +/- ##
==========================================
+ Coverage 82.48% 82.79% +0.30%
==========================================
Files 69 69
Lines 15482 15531 +49
==========================================
+ Hits 12771 12859 +88
+ Misses 2711 2672 -39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The API client's retry loop only honored a retry *count* (TRUNK_API_CLIENT_RETRY_COUNT); the total wall-clock time was otherwise unbounded (per-request timeouts + up to ~62s of exponential backoff across retries), so slow/failing calls could run for minutes. Add an optional overall deadline, read from TRUNK_API_CLIENT_RETRY_DEADLINE_SECS. The retry loop now gives up once the elapsed time plus the next backoff would exceed the budget, returning the most recent error. Pairs with TRUNK_API_CLIENT_RETRY_COUNT to tune how fast and how often the CLI gives up. Replace tokio-retry's RetryIf with an explicit loop so the deadline can short-circuit without needing to construct an error from nothing (the generic A::Error includes reqwest::Error, which has no public constructor). Behavior is identical to before when the deadline is unset. Capture the new env var in bundle metadata for debugging. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f914224 to
bcb832c
Compare
59dad8c to
857a7eb
Compare
acatxnamedvirtue
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The API client's retry loop (
api/src/call_api.rs) only honored a retry count (TRUNK_API_CLIENT_RETRY_COUNT). Total wall-clock time was otherwise uncapped — per-request timeouts plus up to ~62s of exponential backoff (2/4/8/16/32s) across retries — so a slow/failing endpoint could spin for minutes (this is what surfaced the repeated…is taking longer than expectedmessages customers reported).Change
TRUNK_API_CLIENT_RETRY_DEADLINE_SECS: an overall wall-clock budget for a call's retry loop. The loop gives up onceelapsed + next_backoff >= deadline, returning the most recent error. Pairs withTRUNK_API_CLIENT_RETRY_COUNTto tune how fast/often the CLI gives up.tokio-retry'sRetryIfwith an explicit loop (behavior-identical when the deadline is unset) so the deadline can short-circuit while still returning a real error — the genericA::Errorincludesreqwest::Error, which has no public constructor, so atimeout()/select!wrapper couldn't synthesize one. We still usetokio-retry'sExponentialBackoff+Action.LazyLock(DEFAULT_DELAY,RETRY_DEADLINE).TRUNK_API_CLIENT_RETRY_DEADLINE_SECSinTRUNK_ENVS_TO_CAPTUREfor bundle-metadata debugging.Notes
TRUNK_API_CLIENT_RETRY_COUNT=0and/or a smallTRUNK_API_CLIENT_RETRY_DEADLINE_SECS.Testing
stops_retrying_once_deadline_would_be_exceededandretries_full_count_when_no_deadline_set.call_apitests pass; existing retry-count/backoff/should_retrytests unchanged.🤖 Generated with Claude Code