Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto pause on timeout to SDK #568

Open
wants to merge 4 commits into
base: add-pause-and-resume-to-sdk-e2b-1190
Choose a base branch
from

Conversation

dobrac
Copy link
Contributor

@dobrac dobrac commented Jan 31, 2025

Changes the following

  • Adds auto pause to SDK, requires having autoPause: true and auto_pause=True
  • Replaces sandbox resume with connect
  • Updates sandbox timeout on connect if it's already running

SDK Change
The autoPause option is required, and has to be set to true.

JS

Sandbox.create({ autoPause: true })
Sandbox.connect(sandboxId, {autoPause: true})

Python - Async

AsyncSandbox.create(auto_pause=True)
AsyncSandbox.connect(sandbox_id, auto_pause=True)

Python - Sync

Sandbox(auto_pause=True)
Sandbox.connect(sandbox_id, auto_pause=True)

For both Python implementations, the exit now calls .pause() instead of .kill()

Tasks

  • Update interface of connect, resume, etc
  • Add tests for JS SDK
  • Add tests for Python SDK
  • Update web documentation (not for now, until we know the final SDK DX)

Temporary solution for connect
There is a setTimeout for every connect to resolve issues where paused sandbox can immediately timeout.

Options discussed:
1. No set - never sure how long the sandbox will be running
2. Always set the timeout in code - the user can't just connect to the sandbox
without changing the timeout, round trip to the server time
3. Set the timeout in resume on backend - side effect on error
4. Create new endpoint for connect

Copy link

linear bot commented Jan 31, 2025

Copy link

changeset-bot bot commented Jan 31, 2025

⚠️ No Changeset found

Latest commit: 4258d99

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dobrac dobrac self-assigned this Jan 31, 2025
@dobrac dobrac added the Improvement Improvement for current functionality label Jan 31, 2025
@dobrac dobrac force-pushed the add-autopause-option-to-sdk-e2b-1461 branch from d319ba9 to 7c0b99f Compare February 13, 2025 02:36
@dobrac dobrac force-pushed the add-autopause-option-to-sdk-e2b-1461 branch from 7c0b99f to f2ebc1a Compare February 13, 2025 17:53
@dobrac dobrac force-pushed the add-autopause-option-to-sdk-e2b-1461 branch from f2ebc1a to 2a8732e Compare February 13, 2025 17:58
@dobrac dobrac force-pushed the add-autopause-option-to-sdk-e2b-1461 branch from 0443e7b to 7a61bda Compare February 13, 2025 18:51
@dobrac dobrac marked this pull request as ready for review February 13, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improvement for current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant