E2B icon indicating copy to clipboard operation
E2B copied to clipboard

sandbox not killed after trying intentionally to do so

Open pushpitkamboj opened this issue 1 month ago • 3 comments

Describe the bug The sandbox dosen't gets killed even when the code is written to kill it.

To Reproduce i have the code-

async def execute_code(state: State): sandbox = await AsyncSandbox.create(template='slo53v8nmn3kjq80sd59', timeout= 1000) await sandbox.files.make_dir('/home/user/bucket')

await sandbox.files.write('/root/.passwd-s3fs', f'{access_key_id}:{secret_access_key}')
await sandbox.commands.run('sudo chmod 600 /root/.passwd-s3fs')

await sandbox.commands.run(f'sudo s3fs -o url=https://{account_id}.r2.cloudflarestorage.com -o allow_other manim-videos /home/user/bucket')

await sandbox.files.write(f'/home/user/{state["scene_name"]}.py', state["code"]) #create a file scene.py inside the sandbox
try:
    result = await sandbox.commands.run(f'manim --media_dir /home/user/bucket/media -ql /home/user/{state["scene_name"]}.py', timeout=0) #change ql to qh for better resolution
except CommandExitException as error:
    return {
        "sandbox_error": error
    }
await sandbox.kill()

but what i see from the dashboard is the sandbox dosen't get killed. Please help

pushpitkamboj avatar Nov 01 '25 20:11 pushpitkamboj

ENG-3252

linear[bot] avatar Nov 01 '25 20:11 linear[bot]

Hey @pushpitkamboj is it possible that the command failed and the return causes the .kill() to never execute?

try:
    result = await sandbox.commands.run(f'manim --media_dir /home/user/bucket/media -ql /home/user/{state["scene_name"]}.py', timeout=0) #change ql to qh for better resolution
except CommandExitException as error:
    return { #                                    <--------- can return from the program/method
        "sandbox_error": error 
    }

await sandbox.kill() #                            <--------- never reached if return called before

ValentaTomas avatar Nov 01 '25 21:11 ValentaTomas

That is intentional. If the command fails don't kill the sandbox. But if the command succeeds, then do... I observe on the dashboard that it's not getting killed.

pushpitkamboj avatar Nov 02 '25 02:11 pushpitkamboj