Skip to content
Closed
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: 3 additions & 3 deletions packages/js-sdk/src/sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export class Sandbox extends SandboxApi {
*
* @param opts connection options.
*
* @returns sandbox ID that can be used to resume the sandbox.
* @returns `true` if the sandbox got paused, `false` if the sandbox was already paused.
*
* @example
* ```ts
Expand All @@ -585,14 +585,14 @@ export class Sandbox extends SandboxApi {
* ```
*/
async pause(opts?: ConnectionOpts): Promise<boolean> {
return await SandboxApi.pause(this.sandboxId, opts)
return await SandboxApi.pause(this.sandboxId, { ...this.connectionConfig, ...opts })
}

/**
* @deprecated Use {@link Sandbox.pause} instead.
*/
async betaPause(opts?: ConnectionOpts): Promise<boolean> {
return await SandboxApi.betaPause(this.sandboxId, opts)
return await SandboxApi.betaPause(this.sandboxId, { ...this.connectionConfig, ...opts })
}

/**
Expand Down
26 changes: 26 additions & 0 deletions packages/js-sdk/tests/sandbox/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,29 @@ sandboxTest.skipIf(isDebug)(
)
}
)

sandboxTest.skipIf(isDebug || !process.env.E2B_API_KEY)(
'connect propagates apiKey to pause() when E2B_API_KEY is not set',
async ({ sandbox }) => {
// Save the original env var (may be undefined, empty string, or set)
const savedApiKey = process.env.E2B_API_KEY

try {
// Ensure E2B_API_KEY is not set for this test
delete process.env.E2B_API_KEY

// Connect with explicit apiKey taken from the original E2B_API_KEY env var
const connected = await Sandbox.connect(sandbox.sandboxId, {
apiKey: savedApiKey,
})

// pause() should work on the connected sandbox without E2B_API_KEY env var
// It should propagate the apiKey from connectionConfig
const paused = await connected.pause()
expect(typeof paused).toBe('boolean')
} finally {
// Restore original env var
process.env.E2B_API_KEY = savedApiKey
}
}
)
9 changes: 8 additions & 1 deletion packages/python-sdk/e2b_connect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ def _prepare_server_stream_request(
extensions = (
None
if request_timeout is None
else {"timeout": {"connect": request_timeout, "pool": request_timeout}}
else {
"timeout": {
"connect": request_timeout,
"pool": request_timeout,
"read": request_timeout,
"write": request_timeout,
Comment on lines 325 to +333
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description focuses on JS SDK test/comment fixes, but this change also modifies Python SDK streaming request timeout behavior by adding read/write timeouts. Please either update the PR description to mention the Python change (and rationale/impact), or split it into a separate PR to keep scope clear.

Copilot uses AI. Check for mistakes.
}
}
)

if self._compressor is not None:
Expand Down