-
Notifications
You must be signed in to change notification settings - Fork 860
cli: replace sandbox.kill() with setTimeout(1s) in create command to prevent snapshot deletions #1256
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
cli: replace sandbox.kill() with setTimeout(1s) in create command to prevent snapshot deletions #1256
Changes from all commits
d7930c8
4612b72
0bf5632
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@e2b/cli': patch | ||
| --- | ||
|
|
||
| Replace sandbox.kill() with sandbox.setTimeout(1s) in the CLI create command to prevent accidental historic sandbox snapshot deletions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,9 +98,10 @@ export async function connectSandbox({ | |
| sandbox: e2b.Sandbox | ||
| template: Pick<e2b.components['schemas']['Template'], 'templateID'> | ||
| }) { | ||
| // keep-alive loop | ||
| const intervalId = setInterval(async () => { | ||
| await sandbox.setTimeout(30_000) | ||
| // keep-alive loop — track the in-flight promise so we can await it on shutdown | ||
| let pendingKeepAlive: Promise<void> = Promise.resolve() | ||
| const intervalId = setInterval(() => { | ||
| pendingKeepAlive = sandbox.setTimeout(30_000) | ||
| }, 5_000) | ||
|
|
||
| console.log( | ||
|
|
@@ -112,7 +113,8 @@ export async function connectSandbox({ | |
| await spawnConnectedTerminal(sandbox) | ||
| } finally { | ||
| clearInterval(intervalId) | ||
| await sandbox.kill() | ||
| await pendingKeepAlive.catch(() => {}) | ||
| await sandbox.setTimeout(1_000) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Fixed in 4612b72 — the interval callback no longer uses |
||
| console.log( | ||
| `Closing terminal connection to template ${asFormattedSandboxTemplate( | ||
| template | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.