Skip to content

fix(js-sdk): pass connection config to pause() and betaPause()#1230

Open
goingforstudying-ctrl wants to merge 2 commits intoe2b-dev:mainfrom
goingforstudying-ctrl:fix-pause-credentials
Open

fix(js-sdk): pass connection config to pause() and betaPause()#1230
goingforstudying-ctrl wants to merge 2 commits intoe2b-dev:mainfrom
goingforstudying-ctrl:fix-pause-credentials

Conversation

@goingforstudying-ctrl
Copy link
Copy Markdown

Description

Fixes #1215

The pause() and betaPause() methods were not using the connection config passed to Sandbox.connect(), unlike kill() which correctly uses it.

This caused authentication failures when calling pause() after connecting to a sandbox with explicit credentials (e.g., via apiKey option).

Changes

  • Modified pause() to pass { ...this.connectionConfig, ...opts } to SandboxApi.pause()
  • Modified betaPause() to pass { ...this.connectionConfig, ...opts } to SandboxApi.betaPause()

This aligns the behavior with kill(), which already correctly uses the connection config.

Before

const mySandbox = Sandbox.connect(externalId, { apiKey })
mySandbox.kill() // Works ✓
mySandbox.pause() // Fails with auth issue ✗

After

const mySandbox = Sandbox.connect(externalId, { apiKey })
mySandbox.kill() // Works ✓
mySandbox.pause() // Works ✓

The pause() and betaPause() methods were not using the connection config
passed to Sandbox.connect(), unlike kill() which correctly uses it.

This caused authentication failures when calling pause() after connecting
to a sandbox with explicit credentials.

Fixes e2b-dev#1215
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 23, 2026

🦋 Changeset detected

Latest commit: bd90328

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
e2b Patch

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65245eefd2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

*/
async pause(opts?: ConnectionOpts): Promise<boolean> {
return await SandboxApi.pause(this.sandboxId, opts)
return await SandboxApi.pause(this.sandboxId, { ...this.connectionConfig, ...opts })
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid freezing pause() to the original apiUrl

Because ConnectionConfig stores a resolved apiUrl, the spread here also forwards that derived value into SandboxApi.pause(). In packages/js-sdk/src/connectionConfig.ts, the constructor prefers opts.apiUrl over recomputing from domain or debug, so calls like sandbox.pause({ domain: 'staging.e2b.app' }) or sandbox.pause({ debug: true }) will still hit the old control-plane URL after this change unless the caller also overrides apiUrl. Before this patch, pause(opts) still honored those per-call ConnectionOpts, so this regresses non-default domain/debug setups; the same issue is repeated in betaPause() below.

Useful? React with 👍 / 👎.

@ValentaTomas ValentaTomas removed their request for review March 25, 2026 16:22
@goingforstudying-ctrl
Copy link
Copy Markdown
Author

Looks like the upstream main branch now uses resolveApiOpts() which does exactly { ...this.connectionConfig, ...opts } — the same fix this PR introduces.

This PR is effectively redundant since the fix has been addressed in the codebase. Feel free to close this if you agree. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Passed Credential in Sandbox.connect, does not get used in .pause method like in .kill

1 participant