Skip to content

fix: add request-level retry logic for transient errors in HTTP client transport#1497

Open
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:fix/http-client-level-retry-for-transient-errors
Open

fix: add request-level retry logic for transient errors in HTTP client transport#1497
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:fix/http-client-level-retry-for-transient-errors

Conversation

@AdaAibaby

@AdaAibaby AdaAibaby commented Jun 29, 2026

Copy link
Copy Markdown

Closes #1488

Note

cc @mishushakov Would appreciate your review on this change, thanks!
Implements the approach suggested by @mishushakov in #1490 — retries at the HTTP client transport level, not individual methods.

What

  • Python SDK: Override handle_request / handle_async_request in transport classes to retry on transient errors
  • JS SDK: Add withRetry() wrapper around base fetch in http2.ts

All API calls (including wait_for_build_finish polling) automatically get retry support.

Retry strategy

  • Max retries: 3 (configurable via E2B_REQUEST_RETRIES)
  • Backoff: Exponential 1s → 2s → 4s → 8s (capped)
  • Retried: 502/503/504, network/protocol errors (ConnectionTerminated, RemoteProtocolError, etc.)
  • NOT retried: Timeouts, AbortError, 4xx responses

Tests

33 new unit tests (21 Python + 12 JS), all existing tests unaffected.

@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 94b0110

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cla-bot cla-bot Bot added the cla-signed label Jun 29, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Add structured log messages when request-level retries are triggered,
making it easier to diagnose transient failures like h2 ConnectionTerminated.

Python SDK: uses logging.getLogger('e2b.api.retry') at WARNING level
JS SDK: uses console.warn with '[e2b]' prefix

Each log includes: HTTP method, URL, attempt number, backoff delay,
and the failure reason (status code or exception message).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wait_for_build_finish crashes on transient HTTP/2 connection errors (ConnectionTerminated)

2 participants