fix(cli): retry transient gateway errors from the Checkly API [RED-861] [ship] - #1439
Merged
Conversation
Add bounded, backoff-based retries to the shared axios REST instance so one-off 502/503/504/429 gateway blips (and no-response network errors) no longer fail commands and CI pipelines outright. GET/HEAD/OPTIONS retry automatically (3 attempts, full-jitter exponential backoff, base 250ms, per-delay cap 2s, Retry-After honored); mutations can opt in via a new checklyRetry request-config flag where known idempotent. 408, aborted requests, and stream requests/bodies are never retried. Each retry emits a checkly:cli:rest:retry debug line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Split the single delay cap into two knobs: jittered backoff stays capped at 2s, while an explicit Retry-After header is now honored verbatim up to 10s (for 429 and 502/503/504 alike). A 429 asking for more than 10s still gives up; a 5xx asking for more falls back to backoff. Renames maxDelayMs to maxBackoffDelayMs to keep the pair self-describing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sorccu
force-pushed
the
simo/red-861-retry-transient-502s
branch
from
August 14, 2026 03:07
2f1c5a2 to
60e5eee
Compare
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.
Linear: RED-861
What
Adds bounded, backoff-based retries for transient upstream errors to the CLI's axios REST layer, so one-off gateway blips (e.g. a single 502) no longer fail
deploy/test/triggerruns — or our e2e CI — outright.packages/cli/src/rest/retry.ts: a retry rejection-handler registered as the first response interceptor on the shared instance (before the error-mapping interceptor), re-dispatchingapi.request(error.config)so the request interceptor refreshes auth headers on each attempt.Retry-Afterused when ≤ 10 s, else jittered backoff), 429 (Retry-After≤ 10 s honored; > 10 s → no retry; absent → backoff), and no-response network errors (ECONNRESET, ETIMEDOUT, ECONNABORTED, EAI_AGAIN, ERR_NETWORK, EPIPE).checklyRetry: trueconfig flag where the endpoint is known idempotent; no endpoints are opted in yet (mechanism only).Retry-Afteris trusted for longer, up to 10 s per delay. Each retry emits acheckly:cli:rest:retrydebug line (DEBUG=checkly:cli:rest*).Testing
Retry-Afterparsing, abort behavior, stream guards, and the production interceptor wiring/order.ServerError, exits 1; aborting mid-backoff settles immediately instead of waiting out the delay.Known limitations
checkly apisetsvalidateStatus: () => true, so it never rejects and never retries (raw passthrough semantics).deploy/testsubmit requests can never retry (single-use gzip stream bodies); opting in plain-JSON mutations (e.g.env add, trigger) is a candidate follow-up.🤖 Generated with Claude Code