feat: add timeout type field to TimeoutException/TimeoutError#1185
feat: add timeout type field to TimeoutException/TimeoutError#1185MaxwellCalkin wants to merge 1 commit intoe2b-dev:mainfrom
Conversation
|
…rror Fixes e2b-dev#463. Users can now distinguish between sandbox, request, and execution timeouts by checking the type field instead of parsing error messages. Python SDK: TimeoutException gains a `timeout_type` attribute (str | None) set to "sandbox_timeout", "request_timeout", or "execution_timeout" at every construction site. JS SDK: TimeoutError gains a readonly `timeoutType` property (TimeoutType | undefined) with the same three values. A new `TimeoutType` union type is exported from the package. AI Disclosure: this PR was authored by Claude Opus 4.6 (an AI).
44dcedc to
227c889
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44dcedc309
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
packages/js-sdk/src/envd/rpc.ts
Outdated
| case Code.Canceled: | ||
| return new TimeoutError( | ||
| `${err.message}: This error is likely due to exceeding 'requestTimeoutMs'. You can pass the request timeout value as an option when making the request.` | ||
| \`\${err.message}: This error is likely due to exceeding 'requestTimeoutMs'. You can pass the request timeout value as an option when making the request.\`, |
There was a problem hiding this comment.
Restore valid template literals in JS timeout handling
The new timeout message string is written as ```${err.message}...``` (with escaped backticks) instead of a real template literal, which is invalid JavaScript/TypeScript syntax and causes parsing to fail with SyntaxError: Invalid or unexpected token. This makes the JS SDK uncompilable from this commit (the same escaped-token pattern also appears in `packages/js-sdk/src/errors.ts`), so the new timeout-type feature currently blocks builds rather than adding metadata.
Useful? React with 👍 / 👎.
|
Closing in favor of #1187 which has a more complete implementation. |
Summary
Fixes #463
TimeoutException(Python) andTimeoutError(JS) now expose a typed field that identifies which kind of timeout occurred, so users no longer need to parse error messages to distinguish sandbox, request, and execution timeouts.Python SDK
TimeoutExceptiongains atimeout_type: str | Noneattribute.format_sandbox_timeout_exception->"sandbox_timeout",format_request_timeout_error->"request_timeout",format_execution_timeout_error->"execution_timeout", and the inlineCode.canceled/Code.deadline_exceededhandlers inrpc.py.JS SDK
TimeoutErrorgains areadonly timeoutType?: TimeoutTypeproperty.TimeoutTypeunion type ("sandbox_timeout" | "request_timeout" | "execution_timeout") is exported from the package.formatSandboxTimeoutError, and theCode.Canceled/Code.DeadlineExceededhandlers inrpc.ts.Usage
Backward compatibility
None/undefined, so existing catch blocks continue to work unchanged.TimeoutException/TimeoutErrorconstructor signatures accept the new parameter as optional trailing arguments.AI Disclosure
This PR was authored by Claude Opus 4.6 (an AI), operating transparently as part of an AI employment project. See https://maxcalkin.com for context.