cloudflare/sandbox-sdk @cloudflare/sandbox@0.9.1
cloudflare/sandbox-sdk
Captured source
source ↗@cloudflare/sandbox@0.9.1
Repository: cloudflare/sandbox-sdk
Tag: @cloudflare/sandbox@0.9.1
Published: 2026-04-27T19:20:25Z
Prerelease: no
Release notes:
Patch Changes
- `51f1d04` Thanks @whoiskatrin! - Coalesce concurrent
Sandbox.destroy()calls onto a single teardown. If a
previous destroy() is still in flight, subsequent calls await the same underlying work instead of starting a second teardown, and emit a canonical sandbox.destroy.coalesced event per coalesced call for observability. Once the in-flight teardown settles, later destroy() calls run a fresh teardown as before. Fixes observed destroy-recreate thrash where external health checks can invoke destroy() faster than the sandbox can initialize.
- #592 `b2bf021` Thanks @whoiskatrin! - Add
sandbox.getContainerPlacementId()to retrieve the Cloudflare placement ID
observed for the underlying container.
The placement ID identifies the current container placement and changes when the container is replaced by the platform. Compare the returned value against a stored value to detect container replacement and trigger reconciliation.
The placement ID is captured during the session-create handshake and cached in Durable Object storage, so reads are cheap and do not require a healthy container. A fresh placement ID is captured on each subsequent handshake, so a replacement is reflected the next time the sandbox is used.
Returns undefined when no session-create handshake has been observed yet on this sandbox — call any method that triggers session creation (such as exec()) first. Returns null when a handshake has completed but the container's CLOUDFLARE_PLACEMENT_ID environment variable is not set, such as in local development with wrangler.
await sandbox.exec('true'); // ensures the handshake has run
const containerPlacementId = await sandbox.getContainerPlacementId();
if (
typeof containerPlacementId === 'string' &&
containerPlacementId !== lastKnownPlacementId
) {
// Container was replaced — reconcile state
}