Packages

@cloudflare/sandbox

1.0.3 · 22 Oct 2026Apache-2.02.1M / weekRepositoryHomepagenpmAtom feed

Your version

0.9.1

27 Apr 2026Where it was published

0.12.14 is the newest release of 0.9.x.

In short

1 new1 fixed

Release note

Patch Changes

  • 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.

  • 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
    }

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.