Skip to content

fix(python-sdk): stop leaking per-call proxy pools in volume content clients#1534

Open
mishushakov wants to merge 1 commit into
mainfrom
volumes-unclosed-connections
Open

fix(python-sdk): stop leaking per-call proxy pools in volume content clients#1534
mishushakov wants to merge 1 commit into
mainfrom
volumes-unclosed-connections

Conversation

@mishushakov

Copy link
Copy Markdown
Member

The Python volume content client factories passed both proxy and the shared cached transport to httpx, so with a proxy configured (e.g. Volume.connect(volume_id, proxy="http://user:pass@127.0.0.1:8080")), every volume operation mounted a fresh, never-closed proxy transport that bypassed the cached connection pool. The client-level proxy argument is now dropped — the proxy is already baked into the cached transport, so proxied requests keep working but reuse one pooled transport per thread/event loop.

The volume transports also gained connect-level retries (E2B_CONNECTION_RETRIES, default 3), matching the core API and envd transports. Includes a changeset for a @e2b/python-sdk patch release.

🤖 Generated with Claude Code

…clients

The volume content client factories passed both `proxy` and the shared
cached `transport` to httpx. When a proxy was configured, httpx mounted a
fresh, never-closed proxy transport per client — one per volume operation —
bypassing the cached transport entirely. Drop the client-level `proxy`; it
is already baked into the cached transport.

Also add connect-level retries (E2B_CONNECTION_RETRIES, default 3) to the
volume transports, matching the core API and envd transports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Targeted httpx client wiring and transport retry parity; proxied volume traffic should behave the same but reuse pooled connections.

Overview
Fixes a connection-pool leak when volume content clients are used with a proxy: httpx_args no longer passes proxy alongside the shared cached transport, since the proxy is already configured on that transport. Passing both caused httpx to mount a new, never-closed proxy transport on every client creation.

Sync and async volume transports now use connection_retries (E2B_CONNECTION_RETRIES, default 3) at connect time, aligned with the core API and envd transports. Includes a @e2b/python-sdk patch changeset.

Reviewed by Cursor Bugbot for commit f5a3bb4. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f5a3bb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/python-sdk Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Package Artifacts

Built from 361e3e7. Download artifacts from this workflow run.

JS SDK (e2b@2.32.1-volumes-unclosed-connections.0):

npm install ./e2b-2.32.1-volumes-unclosed-connections.0.tgz

CLI (@e2b/cli@2.13.2-volumes-unclosed-connections.0):

npm install ./e2b-cli-2.13.2-volumes-unclosed-connections.0.tgz

Python SDK (e2b==2.31.0+volumes.unclosed.connections):

pip install ./e2b-2.31.0+volumes.unclosed.connections-py3-none-any.whl

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — small, symmetric fix matching the pattern already used by the core API/envd transports (proxy dropped when transport is passed; connect retries added).

Extended reasoning...

Overview

This PR fixes a connection-pool leak in the Python SDK's volume content clients. Only 3 files change: a changeset and the sync/async volume client factories. The substantive change is ~5 lines in each of the two client files: drop "proxy": config.proxy from httpx_args (the proxy is already baked into the cached transport, so passing both caused httpx to mount a fresh, never-closed proxy transport on every client creation), and add retries=connection_retries to the transport constructor.

Security risks

None. The proxy is still honored via the cached transport — proxied traffic keeps working. No auth, crypto, or permission surface is touched.

Level of scrutiny

Low. This is a targeted bug fix that mirrors an established pattern in the same codebase: e2b/api/__init__.py:209-216 already sets httpx_args["proxy"] only when no transport is provided, and tests/test_api_client_transport.py:43,231 already asserts "proxy" not in api_client._httpx_args when a transport is passed. The connection_retries constant (E2B_CONNECTION_RETRIES, default 3) is defined in e2b/api/__init__.py:71 and already used by both the API and envd transports.

Other factors

Sync and async implementations are updated symmetrically as required by CLAUDE.md. A patch-level changeset is included. Cursor Bugbot flagged this as low risk. No outstanding reviewer comments.

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.

1 participant