feat(js-sdk): add proxy connection param#1386
Conversation
Add a `proxy` connection parameter to the JS SDK, matching the Python SDK. When set, requests are routed through the given HTTP proxy via an undici ProxyAgent dispatcher. It applies to control-plane API requests, all requests made to the returned sandbox (REST + filesystem/commands/pty RPC), and volume requests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ca31cbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
PR SummaryMedium Risk Overview Python and JS volumes now keep Reviewed by Cursor Bugbot for commit ca31cbe. Bugbot is set up for automated code reviews on this repo. Configure here. |
Package ArtifactsBuilt from 61960c9. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.28.1-mishushakov-add-proxy-connection-param.0.tgzCLI ( npm install ./e2b-cli-2.10.5-mishushakov-add-proxy-connection-param.0.tgzPython SDK ( pip install ./e2b-2.26.0+mishushakov.add.proxy.connection.param-py3-none-any.whl |
Use createApiFetch unconditionally for consistency with the main API client, rather than only routing through it when a proxy is set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12603e4d69
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
LGTM — opt-in proxy parameter mirrors the Python SDK, with per-proxy fetcher caching and good test coverage.
Extended reasoning...
Overview
Adds an optional proxy connection parameter to the JS SDK that routes traffic through an undici ProxyAgent when set. The change threads the proxy URL through three fetch surfaces — control-plane API (api/index.ts), sandbox envd REST/RPC (sandbox/index.ts), and volume client (volume/client.ts) — by extending ConnectionConfig/VolumeConnectionConfig with a proxy field. Per-proxy fetcher caching (Map<string, typeof fetch>) replaces the previous single-instance memoization, so non-proxy traffic still shares a dispatcher.
Security risks
Minimal. This is opt-in networking config — no proxy means no behavior change, and the dispatcher selection is a simple ternary inside an already-trusted code path. The proxy URL can embed credentials, but that's the standard http://user:pass@host form documented in the JSDoc. No auth, crypto, or permissions code is touched.
Level of scrutiny
Low. This is sandbox SDK plumbing, not a production-critical control plane. The change pattern is mechanical — extend options, thread one new param through factories, swap Agent for ProxyAgent when set — and mirrors a feature already shipped in the Python SDK. New unit tests cover both ProxyAgent wiring and the per-proxy caching invariant for API and envd fetchers.
Other factors
The author self-reviewed and consolidated the volume client to use createApiFetch unconditionally for consistency with the main API client (resolved in 12603e4). The bug hunting system found no issues, and Cursor Bugbot independently flagged this as Low Risk. The changeset is included and marked as a patch bump.
matthewlouisbrockman
left a comment
There was a problem hiding this comment.
Not sure the env auto detection is a patch change here; it's possibly breaking and there's no off switch.
I've seen it before where when you have _PROXY env supported you also have a no_proxy bypass which we probably want to at least be able to opt out, although if want to keep a patch, we should probably make the env reading opt in rather than opt out? IMO lighter touch of opt in probably better but not too opinionated.
Tangentially, reading HTTP_PROXY as cursor pointed out above is risky; some servers have vulns there
0021117 to
12603e4
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 12603e4. Configure here.
Volume.create/connect honored proxy only on the control-plane call; the returned Volume instance dropped it, so instance methods (list, readFile, writeFile, makeDir, getInfo, updateMetadata, remove) bypassed the proxy unless it was re-passed on every call. Store the proxy on the Volume instance and fall back to it in VolumeConnectionConfig (matching the domain/debug/token pattern). A per-call proxy still takes precedence. Applied to JS and both Python sync/async SDKs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@matthewlouisbrockman I've dropped the env var for now, also fixed the Volume instance proxy inheritance. |
Merge artifact from the API-only header options change left a `/** ` with a trailing space, failing the format check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Adds a
proxyconnection parameter to the JS SDK, mirroring the Python SDK. When set, requests are routed through the given HTTP proxy via an undiciProxyAgentdispatcher (fetchers are cached per-proxy so non-proxy traffic is unaffected). It applies to control-plane API requests, all requests made to the returned sandbox (REST plus filesystem/commands/pty RPC), and volume requests. Behavior is unchanged when no proxy is provided, and unit tests cover both the API and envd fetch paths.Usage
🤖 Generated with Claude Code