Repository navigation
feat(sdk): switch domain from X-E2B-Alt-Used response header - #2001
devin-ai-integration[bot] wants to merge 6 commits into
Conversation
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
🦋 Changeset detectedLatest commit: c893d9c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Package ArtifactsBuilt from 7eec354. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.2-devin-1792498715-alt-used-domain.0.tgz ./e2b-2.58.1-devin-1792498715-alt-used-domain.0.tgzCLI ( npm install ./e2b-cli-2.22.4-devin-1792498715-alt-used-domain.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.9.1-devin-1792498715-alt-used-domain.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.5.1-devin-1792498715-alt-used-domain.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.1+devin.1792498715.alt.used.domain-py3-none-any.whl ./e2b-2.58.0+devin.1792498715.alt.used.domain-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.11.2+devin.1792498715.alt.used.domain-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.7.2+devin.1792498715.alt.used.domain-py3-none-any.whl |
There was a problem hiding this comment.
TASTE.md review of #2001 (X-E2B-Alt-Used domain switching).
Checked: parity JS / sync / async Python (T-1, T-2), configuration precedence & immutability (T-49, T-50, T-51), client-side validation scope (T-52), debug mode (T-53), entry-point/exports (T-54), naming & named constants (T-12, T-47), null/undefined at the boundary (T-20), docs (T-69).
Violations: 1 rule (T-49), flagged inline in both JS and Python. Parity is otherwise good: Python retries run in the transport under httpx, so the response hook sees the final response just like the JS wrapper after withRetry; the async client gets its own async hook; debug mode is respected; the hostname check on the header is a legitimate footgun guard under T-52; the new modules stay internal.
Not tied to a changed line:
- T-69: the public
domainoption docs (JSConnectionOpts.domain,@default E2B_DOMAIN // environment variable or e2b.app; PythonApiParams.domain) still describe the old resolution. Whatever precedence this lands with, the docstrings should say the effectivedomain/apiUrlmay be replaced by the control-plane domain the API reports, and when that does not happen (customapiUrl/E2B_API_URL, debug). - Outside TASTE: the PR description says proxies never record or switch, but
usesDomainApiUrl/uses_domain_api_urlonly look atdomain,apiUrlanddebug. Withproxyset and the defaultapiUrl, both recording and switching still happen. Either the code or the description should change.
mishushakov
left a comment
There was a problem hiding this comment.
I think we should always use E2B_DOMAIN, E2B_API_URL, E2B_SANDBOX_URL, E2B_VOLUME_API_URL
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
|
@mishushakov Done in 8348a79. When any of Explicit options ( |
|
you don't need to check the particular env vars, just check whether domain, apiUrl, sandboxUrl are specified |
…dboxUrl Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
|
@mishushakov Done in c893d9c (plus 81e4abd, a docstring nit). The env-var list is gone. Discovery now runs only when
One trade-off: configs rebuilt with |
Summary
The global API proxy responds with
X-E2B-Alt-Used: <full domain>(e.g.e2b-juliett.dev), which names the control plane that owns the API key. The SDKs (JS and sync/async Python) now remember that domain for the rest of the process and send later traffic straight to that plane.resolvedDomains.ts/e2b/resolved_domains.py, lock-protected in Python). Every static call builds a new config, so switching only one instance wouldn't carry over to the next call.domain,apiUrlorsandboxUrlis set, whether as an option or viaE2B_DOMAIN/E2B_API_URL/E2B_SANDBOX_URL. The constructor computes this once asConnectionConfig.discoverDomain(_discover_domainin Python).new ConnectionConfig({ ...config })passdomainexplicitly, so they neither record nor switch. Fresh configs do both. So with an empty cache, the firstSandbox.createkeeps the default domain, and later calls pick up the discovered one.ConnectionConfig.domainchanges, so the sandbox-domain fallback (sandboxDomain ?? domain) follows it. envd traffic then reaches the right plane when the API returns no sandbox domain.withRetry. envd, the volume-content client and the CLI are unchanged.Not tested end to end: production doesn't send the header yet. The switching is covered by mocked tests (MSW /
httpx.MockTransport). A live create →echo ok→ kill smoke test in both SDKs only checks that nothing else broke.Link to Devin session: https://app.devin.ai/sessions/d9d825e6b83d4d0489e930619a7621c0
Open in Devin Desktop: https://app.devin.ai/desktop/session/d9d825e6b83d4d0489e930619a7621c0?variant=devin
Requested by: @mishushakov