From ed97ed95ea812b2efdf7f0074ac19decebf2143c Mon Sep 17 00:00:00 2001 From: Claude Code Bot Date: Sat, 9 May 2026 14:53:38 -0700 Subject: [PATCH 1/2] feat: retry op read with exponential backoff for flaky wifi Single timeout fails on slow connections; retrying with 2s/4s/8s backoff gives 3 chances across ~14s without penalizing fast networks. Co-Authored-By: Claude Opus 4.6 --- lib/credentials.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/credentials.sh b/lib/credentials.sh index 2440da8..a31036f 100755 --- a/lib/credentials.sh +++ b/lib/credentials.sh @@ -74,11 +74,21 @@ _load_gh_token() { fi local token - if command -v timeout &>/dev/null; then - token="$(timeout 5 op read "${_CREDS_GH_TOKEN_REF}" 2>/dev/null || true)" - else - token="$(op read "${_CREDS_GH_TOKEN_REF}" 2>/dev/null || true)" - fi + local -a backoff=(2 4 8) + local has_timeout=false + command -v timeout &>/dev/null && has_timeout=true + + for wait_secs in "${backoff[@]}"; do + if "${has_timeout}"; then + token="$(timeout "${wait_secs}" op read "${_CREDS_GH_TOKEN_REF}" 2>/dev/null || true)" + else + token="$(op read "${_CREDS_GH_TOKEN_REF}" 2>/dev/null || true)" + fi + if [[ -n "${token}" ]]; then + break + fi + debug_log "op read attempt timed out after ${wait_secs}s, retrying…" + done if [[ -n "${token}" ]]; then export GH_TOKEN="${token}" From ffc362e43193ace7852025379c75814e7d123a93 Mon Sep 17 00:00:00 2001 From: Claude Code Bot Date: Sat, 9 May 2026 14:57:13 -0700 Subject: [PATCH 2/2] fix: declare wait_secs local and clarify debug message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses review feedback: variable leaked into function scope, and "retrying…" was misleading on the final attempt. Co-Authored-By: Claude Opus 4.6 --- lib/credentials.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/credentials.sh b/lib/credentials.sh index a31036f..1ce66f1 100755 --- a/lib/credentials.sh +++ b/lib/credentials.sh @@ -76,6 +76,7 @@ _load_gh_token() { local token local -a backoff=(2 4 8) local has_timeout=false + local wait_secs command -v timeout &>/dev/null && has_timeout=true for wait_secs in "${backoff[@]}"; do @@ -87,7 +88,7 @@ _load_gh_token() { if [[ -n "${token}" ]]; then break fi - debug_log "op read attempt timed out after ${wait_secs}s, retrying…" + debug_log "op read failed (timeout ${wait_secs}s)" done if [[ -n "${token}" ]]; then