Skip to content

fix: extend withRetry to handle transient network errors#30

Open
consumeobeydie wants to merge 1 commit into
circlefin:masterfrom
consumeobeydie:fix/retry-network-errors
Open

fix: extend withRetry to handle transient network errors#30
consumeobeydie wants to merge 1 commit into
circlefin:masterfrom
consumeobeydie:fix/retry-network-errors

Conversation

@consumeobeydie

Copy link
Copy Markdown

Problem

The withRetry function in lib/circle/gateway-sdk.ts only retries on rate limit errors (HTTP 429). Transient network errors like ECONNRESET, ETIMEDOUT, ECONNREFUSED, and fetch failed are not retried, causing unnecessary failures in unstable network conditions.

Fix

Extended the retry condition to include common transient network errors:

  • ECONNRESET — connection reset by peer
  • ETIMEDOUT — connection timed out
  • ECONNREFUSED — connection refused
  • fetch failed — generic fetch failure

The log message now distinguishes between rate limit retries and network error retries for easier debugging.

Changes

  • lib/circle/gateway-sdk.ts — extended isRetryable check to include network errors alongside rate limit errors

Impact

  • Reliability: Treasury operations are now resilient to transient network failures
  • Risk: Low — only adds retry cases, preserves all existing behavior
  • Performance: No change for the happy path

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