Skip to content

feat: retry failed Bunny operations with exponential backoff#3

Merged
agarciar merged 1 commit into
mainfrom
feat/upload-retry
May 25, 2026
Merged

feat: retry failed Bunny operations with exponential backoff#3
agarciar merged 1 commit into
mainfrom
feat/upload-retry

Conversation

@agarciar
Copy link
Copy Markdown
Contributor

Adds resilience to transient Bunny API failures (5xx / network blips) during a deploy. Driven by tests first (TDD).

What

  • New src/retry.tswithRetry(fn, { retries, baseDelayMs, onRetry }): runs fn, and on rejection waits with exponential backoff + jitter and retries, up to retries extra attempts, then rethrows the last error.
  • BunnyClient wiringupload, remove, purgePullZone, and each list in listAll now go through withRetry, logging a warn per retry. Uploads re-open the read stream inside the retried fn (a stream is single-use, so a naive retry would send truncated data).
  • New retries option (schema.json + DeployOptions, default 3, minimum: 0; 0 = fail fast). Threaded from deploy.ts into the client.
  • README options table + CHANGELOG updated.

Behaviour with the existing flow

Uploads retry before runWithConcurrency aborts; deletes retry before being counted as a best-effort failure; the purge retries before the orchestrator downgrades it to a warning. No change to that orchestration logic.

Verification

  • pnpm test42/42 (+6: full withRetry unit suite + a BunnyClient upload-retry test that also closes the previously-untested upload path). Both confirmed RED before the implementation.
  • pnpm run typecheck clean, pnpm run build + dist smoke OK.

🤖 Generated with Claude Code

Transient 5xx/network errors during upload, delete, list, or purge aborted
the whole deploy. Add a withRetry helper (exponential backoff + jitter) and
wrap every BunnyClient network call in it, logging each retry. Uploads
re-open the read stream per attempt (streams are single-use). Exposed as a
new `retries` builder option (default 3, 0 = fail fast).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@agarciar agarciar merged commit 21d6c9c into main May 25, 2026
7 checks passed
@agarciar agarciar deleted the feat/upload-retry branch May 25, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant