Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tidy-sdk-dead-code.md
Original file line number Diff line number Diff line change
@@ -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`
1 change: 0 additions & 1 deletion packages/js-sdk/src/connectionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
32 changes: 12 additions & 20 deletions packages/js-sdk/src/sandbox/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import {
handleProcessStartEvent,
} from '../../envd/api'
import {
ConnectResponse,
Process as ProcessService,
Signal,
StartResponse,
} from '../../envd/process/process_pb'
import {
authenticationHeader,
Expand Down Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -465,6 +448,15 @@ export class Commands {
}
)

return this.createHandle(events, clearStartTimeout, cleanup, opts)
}

private async createHandle(
events: AsyncIterable<StartResponse | ConnectResponse>,
clearStartTimeout: () => void,
cleanup: () => void,
opts?: Pick<CommandStartOpts, 'onStdout' | 'onStderr'>
): Promise<CommandHandle> {
try {
const pid = await handleProcessStartEvent(events)
clearStartTimeout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading