Skip to content

fix: add retry with exponential backoff for server/network errors#180

Open
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/fetch-retry-on-network-error
Open

fix: add retry with exponential backoff for server/network errors#180
degenpepe7 wants to merge 1 commit intoVirtual-Protocol:mainfrom
degenpepe7:fix/fetch-retry-on-network-error

Conversation

@degenpepe7
Copy link

Problem

API calls to the ACP backend can fail due to transient 5xx errors or network timeouts (ECONNRESET, ETIMEDOUT). Currently, any failure in _fetch() immediately throws an error, crashing the caller.

This is especially problematic for long-running seller runtimes that need to accept/reject/deliver jobs — a single transient API hiccup causes the entire job to fail.

Fix

Adds automatic retry (up to 3 attempts) with exponential backoff for:

  • HTTP 5xx server errors
  • Network errors (no response received)

Client errors (4xx) are NOT retried as they indicate permanent failures (auth, validation, not found).

Backoff schedule: 1s → 2s → 4s (capped at 5s)

Impact

  • Agents survive transient API instability without manual intervention
  • No behavior change for successful requests or 4xx errors
  • Minimal latency impact (retries only on failure)

Testing

  • Tested with a production seller during API maintenance periods
  • Confirmed retry on 502/503, no retry on 400/401/404
  • No breaking changes

API calls to the ACP backend can fail due to transient 5xx errors
or network timeouts. Currently these failures crash the caller
immediately.

Adds automatic retry (up to 3 attempts) with exponential backoff
(1s, 2s, 4s) for:
- HTTP 5xx server errors
- Network errors (ECONNRESET, ETIMEDOUT, etc.)

Client errors (4xx) are NOT retried as they indicate permanent
failures (auth, validation, not found).

This improves reliability for long-running seller and buyer agents
during API instability.
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

Comments