diff --git a/.changeset/tidy-sdk-dead-code.md b/.changeset/tidy-sdk-dead-code.md new file mode 100644 index 0000000000..f19a30f43b --- /dev/null +++ b/.changeset/tidy-sdk-dead-code.md @@ -0,0 +1,6 @@ +--- +'e2b': patch +'@e2b/python-sdk': patch +--- + +Remove unused internal constants and attributes, and share the command handle setup between `Commands.run` and `Commands.connect` diff --git a/packages/js-sdk/src/connectionConfig.ts b/packages/js-sdk/src/connectionConfig.ts index a9ef7fdf84..366c30d070 100644 --- a/packages/js-sdk/src/connectionConfig.ts +++ b/packages/js-sdk/src/connectionConfig.ts @@ -8,7 +8,6 @@ const supportedDomains = ['e2b.app', 'e2b.dev', 'e2b.pro', 'e2b-staging.dev'] export const REQUEST_TIMEOUT_MS = 60_000 // 60 seconds export const DEFAULT_RETRIES = 3 -export const DEFAULT_SANDBOX_TIMEOUT_MS = 300_000 // 300 seconds export const KEEPALIVE_PING_INTERVAL_SEC = 50 // 50 seconds export const KEEPALIVE_PING_HEADER = 'Keepalive-Ping-Interval' diff --git a/packages/js-sdk/src/sandbox/commands/index.ts b/packages/js-sdk/src/sandbox/commands/index.ts index 22c9a4028d..a9905d084d 100644 --- a/packages/js-sdk/src/sandbox/commands/index.ts +++ b/packages/js-sdk/src/sandbox/commands/index.ts @@ -21,8 +21,10 @@ import { handleProcessStartEvent, } from '../../envd/api' import { + ConnectResponse, Process as ProcessService, Signal, + StartResponse, } from '../../envd/process/process_pb' import { authenticationHeader, @@ -350,26 +352,7 @@ export class Commands { } ) - try { - const pid = await handleProcessStartEvent(events) - clearStartTimeout() - - return new CommandHandle( - pid, - cleanup, - () => this.kill(pid), - events, - opts?.onStdout, - opts?.onStderr, - undefined, - (data, stdinOpts) => this.sendStdin(pid, data, stdinOpts), - (stdinOpts) => this.closeStdin(pid, stdinOpts), - this.checkHealth - ) - } catch (err) { - cleanup() - throw await handleRpcErrorWithHealthCheck(err, this.checkHealth) - } + return this.createHandle(events, clearStartTimeout, cleanup, opts) } /** @@ -465,6 +448,15 @@ export class Commands { } ) + return this.createHandle(events, clearStartTimeout, cleanup, opts) + } + + private async createHandle( + events: AsyncIterable, + clearStartTimeout: () => void, + cleanup: () => void, + opts?: Pick + ): Promise { try { const pid = await handleProcessStartEvent(events) clearStartTimeout() diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py index 725662fad0..76ca51e329 100644 --- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py +++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py @@ -91,7 +91,6 @@ def __init__( connection_config: ConnectionConfig, envd_api: httpx.AsyncClient, ) -> None: - self._envd_api_url = envd_api_url self._envd_version = envd_version self._connection_config = connection_config self._rpc = create_rpc_client( diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py index d3a2ba6463..752d4999a7 100644 --- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py +++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py @@ -85,7 +85,6 @@ def __init__( connection_config: ConnectionConfig, envd_api: httpx.Client, ) -> None: - self._envd_api_url = envd_api_url self._envd_version = envd_version self._connection_config = connection_config self._rpc = create_rpc_client(