Skip to content

Optimize Beam JS sandbox lifecycle and command startup - #49

Closed
luke-lombardi wants to merge 4 commits into
mainfrom
codex/inline-sandbox-exec
Closed

Optimize Beam JS sandbox lifecycle and command startup#49
luke-lombardi wants to merge 4 commits into
mainfrom
codex/inline-sandbox-exec

Conversation

@luke-lombardi

@luke-lombardi luke-lombardi commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Add the sandbox wait exec option and consume inline exit status/stdout/stderr responses.
  • Avoid follow-up status and output requests when a short blocking command completes inline.
  • Singleflight shared runtime preparation so concurrent sandbox creates do not race image/file synchronization.
  • Add concurrency and inline-result regression coverage.
  • Bump the SDK version to 1.0.13.
  • Preserve the sandbox parity, examples, and e2e coverage already present on this branch.

Why

ComputeSDK's node -v probe paid several avoidable HTTP round trips and a 100 ms polling interval after every sandbox became ready. Concurrent first-use creates could also collide in file synchronization and fail with Sync already in progress.

Impact

With the coordinated beta9 polling change, the latest-upstream ComputeSDK production-order run completed:

  • sequential: 100/100, median 169.5 ms, reported p99 214.9 ms
  • staggered: 100/100, median 156.5 ms, reported p99 228.8 ms

Validation

  • npm test -- --runInBand — 140 passed, 3 skipped
  • npm run build — CJS and ESM builds clean
  • npm pack --dry-run — package validated as 1.0.13
  • Latest ComputeSDK benchmark upstream with the published 1.0.12 package patched only with this candidate

Summary by cubic

Improves sandbox startup and stability with inline exec results, transient retries, and shared runtime preparation. Also adds Docker support, filesystem helpers, sandbox examples, and opt-in e2e tests; workspaceId is now optional.

  • New Features

    • Exec supports wait to return inline exitCode/stdout/stderr for short commands; added execShell, status/poll/wait, and server-backed listProcesses.
    • Filesystem helpers: writeText/writeBytes, readText/readBytes, and remove.
    • Docker-in-Docker: Image.withDocker() and SandboxDockerManager (docker.version, docker.run, docker.compose); ensures daemon readiness and uses host network/pid namespaces.
    • Added sandbox examples and production e2e tests (Docker tests are opt-in).
  • Performance

    • Avoids follow-up status/output requests for short blocking commands via inline wait; reduces polling and round trips.
    • Singleflight runtime preparation to prevent first-use sync races; added transient retry for status/stdout/stderr calls.

Written for commit adcf058. Summary will update on new commits.

Review in cubic

Copy link
Copy Markdown
Contributor Author

Superseded by beam-cloud/beam-client#74. The publishable JavaScript SDK source now lives under beam-client/js; the replacement PR contains only the canonical source and tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant