E2B icon indicating copy to clipboard operation
E2B copied to clipboard

[Bug]: Sandbox gets deleted with no warning

Open rudra-sett opened this issue 6 months ago • 2 comments

Sandbox ID or Build ID

iz62km2v0zwlow3i7icxv

Environment

e2b==2.10.2, e2b-code-interpreter==2.4.1, Python 3.12.13, macOS (local dev) / Linux GCC 13.3.0 (production K8s workers)

Timestamp of the issue

2026-06-01T21:37:32Z UTC, 2026-06-02T14:15:53Z UTC

Frequency

Occasional occurrence

Expected behavior

Sandbox should remain alive and reachable for the full duration of the configured timeout (300s and 7200s respectively). Operations against the sandbox (commands.run, files.read, files.write) should succeed until the timeout expires or the sandbox is explicitly killed by the client.

Actual behavior

Sandbox is silently deleted by E2B infrastructure well before the configured timeout. No warning, error callback, or status change is surfaced before the sandbox disappears. Subsequent operations fail with:

e2b_connect.client.ConnectException: (<Code.unavailable: 'unavailable'>, 'The sandbox was not found')

The error message suggests a timeout, but the sandbox was alive for only ~28 seconds (timeout=300) and ~34 minutes (timeout=7200) respectively.

Issue reproduction

Intermittent - occurs on roughly 1-3% of sandbox runs. We have not found a reliable single-shot reproduction. Factors that may increase likelihood:

  1. Multiple sandboxes created concurrently on the same process (shared httpx connection pool)
  2. Custom templates
  3. Sandboxes under active load (agent running, streaming stdout via commands.run with on_stdout callback)

Minimal reproduction attempt:

from e2b_code_interpreter import Sandbox

sandbox = Sandbox.create(timeout=300)
print(f"Created: {sandbox.sandbox_id}")

# Prove sandbox is alive
result = sandbox.commands.run("echo hello")
print(f"Alive: {result.stdout}")

# In our case, the sandbox dies somewhere in the next 30-60 seconds
# while running a long-lived command via sandbox.commands.run(cmd, 
#   timeout=180, on_stdout=callback)

Additional context

We run E2B sandboxes at scale (~hundreds/day) from Celery workers in a Kubernetes cluster. The sandboxes execute for 30 minutes to several hours.

We've instrumented comprehensive retry and reconnection logic (exponential backoff, httpcore connection pool eviction, background process reconnection via commands.connect(pid=pid)). This lets us distinguish between three failure modes:

  1. HTTP/2 stream breaks (transient, recoverable) -- stream drops but sandbox is alive, process keeps running, we reconnect successfully
  2. Stale connection pool (transient, recoverable) -- RECV_PING in ConnectionState.CLOSED, fixed by evicting dead connections and retrying
  3. Sandbox genuinely gone (this bug) -- sandbox.commands.list() fails, POST /sandboxes/{id}/pause returns 404, no recovery possible

This issue is specifically about case 3. Our telemetry (Sentry) shows the sandbox returning 404 on the pause API call at cleanup time (which is well within the 2 hour timeout we start sandboxes with), suggesting E2B's infrastructure deleted the sandbox, not a network issue on our end.

Another sandbox example (older) which ran into the issue at 34 minutes: i70u6lq6rgn7tzmc0zia6 The one posted above was the one that died in 33 seconds: iz62km2v0zwlow3i7icxv

rudra-sett avatar Jun 02 '26 20:06 rudra-sett

ENG-4235

linear-code[bot] avatar Jun 02 '26 20:06 linear-code[bot]

Hi @rudra-sett, I apologize for the inconvenience. This sandbox was killed due to the incident we've had today https://status.e2b.dev/incidents/01KT4JAXRXFXQF557YYQV8EG5P

The situation has now been resolved, and everything is fully operational again. This should not happen going forward.

Please let me know if you encounter any issues going forward.

beran-t avatar Jun 02 '26 20:06 beran-t