ReleaseCloudflare (Workers AI)Cloudflare (Workers AI)published Apr 24, 2026seen Jun 26

cloudflare/sandbox-sdk @cloudflare/sandbox@0.9.0

cloudflare/sandbox-sdk

Open original ↗

Captured source

source ↗
published Apr 24, 2026seen Jun 26captured 4whttp 200method plain

@cloudflare/sandbox@0.9.0

Repository: cloudflare/sandbox-sdk

Tag: @cloudflare/sandbox@0.9.0

Published: 2026-04-24T17:24:56Z

Prerelease: no

Release notes:

Minor Changes

  • #633 `4e628ae` Thanks @whoiskatrin! - Handle shell exits with SessionTerminatedError, and let the same session id recover on the next call.
import { SessionTerminatedError } from '@cloudflare/sandbox';

const session = await sandbox.createSession({ id: 'build' });

try {
await session.exec('exit 42');
} catch (error) {
if (error instanceof SessionTerminatedError) {
console.log(error.exitCode); // 42
await session.exec('echo fresh shell');
}
}

If a session's shell exits, the failing call now returns SESSION_TERMINATED (HTTP 410) with the observed exit code instead of a generic internal error. Retrying with the same session id, or calling createSession({ id }), starts a fresh session without destroying the whole sandbox. Session-local state such as the working directory, environment variables, shell functions, and background jobs is lost when the shell exits.