fix(sdk): consistent rate limit error for envd 429 responses#1387
Conversation
The main API client already raised RateLimitError/RateLimitException for HTTP 429, but the envd HTTP and RPC layers fell through to a generic sandbox error. Map envd 429 and gRPC ResourceExhausted to the dedicated rate limit error across the JS SDK and Python sync/async SDKs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR SummaryLow Risk Overview Callers can Also removes a duplicate Reviewed by Cursor Bugbot for commit 633cc8a. Bugbot is set up for automated code reviews on this repo. Configure here. |
🦋 Changeset detectedLatest commit: 633cc8a 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 |
Package ArtifactsBuilt from 7212ea5. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.27.2-mishushakov-consistent-rate-limit-error.0.tgzCLI ( npm install ./e2b-cli-2.10.4-mishushakov-consistent-rate-limit-error.0.tgzPython SDK ( pip install ./e2b-2.25.1+mishushakov.consistent.rate.limit.error-py3-none-any.whl |
The request_timeout was assigned via _get_request_timeout and then immediately overwritten by an inline copy of the same logic. Keep only the helper call; no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Python package is published as @e2b/python-sdk and is not linked/fixed with the JS "e2b" package, so the Python changes would have been missed by the release workflow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
matthewlouisbrockman
left a comment
There was a problem hiding this comment.
lgtm... i think there's an edge case in js-sdk/envd/api.ts where we're checking against !res.error instead of res.error === undefined but can do that in future PR cause not related to the 429 fix
Summary
The main API client already raised
RateLimitError(JS) /RateLimitException(Python) for HTTP 429, but the lower-level envd HTTP and RPC layers fell through to a generic sandbox error, so the same rate-limit condition surfaced as a different type depending on which request path hit it. This maps envd 429 (and the equivalent gRPCResourceExhaustedcode) to the dedicated rate-limit error consistently across the JS SDK and the Python sync/async SDKs. The JS RPC layer was also missing theResourceExhaustedmapping entirely, which is now added for parity with Python.Also includes a small Python-SDK cleanup:
ConnectionConfigsetrequest_timeoutvia_get_request_timeoutand then immediately overwrote it with an inline copy of the same logic — the duplicate block is removed (no behavior change).Changes
js-sdk/src/envd/api.ts,python-sdk/e2b/envd/api.py— envd HTTP 429 →RateLimitError/RateLimitExceptionjs-sdk/src/envd/rpc.ts— added gRPCCode.ResourceExhausted→RateLimitErrorpython-sdk/e2b/connection_config.py— removed redundantrequest_timeoutreassignmente2b: patch)Usage example
🤖 Generated with Claude Code