Cancellation & Cleanup

Resource cleanup and error handling when commands fail or time out.

cancellation

Demonstrates resource cleanup and error handling patterns when commands fail or time out.

Setup

bunx alineo-cli init   # starts OpenSandbox in Docker (one-time setup)

Run

bun install
bun start

What it shows

PatternDescription
try/finallyGuarantees sb.close() runs even when an exec throws
Bash timeoutLimits a command's wall-clock time at the shell level
CommandErrorCatching the error thrown by a non-zero exit code

Three sandboxes run sequentially, each demonstrating one pattern.