Repository navigation
fix(sandbox): keep reused E2B workbench leases within the runtime cap - #8758
Conversation
E2B kills a running sandbox 24h after it last started or resumed and silently clamps any longer timeout. Reconnecting to a workbench late in its life recorded a lease past that cap, so outlives() skipped the extension and a run cut off at the cap was reported as a user timeout. - Track the cap on every handle and never record a session deadline past it - Pause and resume a running workbench whose lease cannot fit before its cap, which resets E2B's runtime count with files and processes intact - Classify a timeout at the cap of a reconnected workbench as provider_limit
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
…d would outlive it
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/execution/remote-sandbox/e2b.ts">
<violation number="1" location="apps/sim/lib/execution/remote-sandbox/e2b.ts:503">
P2: `commandDeadlineAtMs` is captured before process recording and E2B dispatch, although `timeoutMs` starts when `commands.run` starts. Near the 24-hour cap, setup delay can make an E2B provider timeout return as `timedOut` instead of `provider_limit`; capture the timestamp immediately before dispatch.</violation>
</file>
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
findSessionSandboxrecordedrequestedAt + max(5min, endAt - now, lease)as the session deadline, so a workbench reconnected late in its life claimed a lease past the cap,outlives()skipped the extension, and E2B killed the workbench mid-runstartedAt + 24h, or the connect time when resuming a paused workbench), and the session deadline is clamped to it in one place, covering both the reconnect andextendLifetimeSandbox.pause) and resumed through the existingSandbox.connect, which restarts E2B's runtime count with files, packages and processes intact instead of replacing the workbenchprovider_limitinstead of a user-code timeout (exit 124), sinceproviderLimitAtMswas previously only set on a fresh create with exactly a 24h lifetime. A timeout counts as the cap only when the command's own deadline, measured from E2B dispatch, would have outlived it, so a short command timing out near the cap stays a user timeoutType of Change
Testing
E2B continuous-runtime capcases ine2b-session.test.tsrun against a fake control plane that clamps timeouts to the cap and restarts it on resume: capped deadline when pausing fails (including afterextendLifetime), pause + resume when the lease cannot fit, andprovider_limitat the cap. All three fail on the previous code; reverting each guard individually turns its test redsession-files.test.ts/session-file-snapshot.test.tsthat fail when the reconnect is not asked for the idle leaselib/execution/remote-sandbox/+lib/mothershipsuites,bun run lint,bun run type-check,bun run check:audits,docs-manifest:check, block-registry checkbun run testChecklist
test-auditauthoring gate)