modal
    Preparing search index...

    Class Sandbox

    Sandboxes are secure, isolated containers in Modal that boot in seconds.

    Index

    Properties

    sandboxId: string
    stderr: ModalReadStream<string>
    stdin: ModalWriteStream<string>
    stdout: ModalReadStream<string>

    Methods

    • Check if the Sandbox has finished running.

      Returns null if the Sandbox is still running, else returns the exit code.

      Returns Promise<null | number>

    • Set tags (key-value pairs) on the Sandbox. Tags can be used to filter results in Sandbox.list.

      Parameters

      • tags: Record<string, string>

      Returns Promise<void>

    • Snapshot the filesystem of the Sandbox.

      Returns an Image object which can be used to spawn a new Sandbox with the same filesystem.

      Parameters

      • timeout: number = 55000

        Timeout for the snapshot operation in milliseconds

      Returns Promise<Image>

      Promise that resolves to an Image

    • Get Tunnel metadata for the Sandbox.

      Raises SandboxTimeoutError if the tunnels are not available after the timeout.

      Parameters

      • timeout: number = 50000

      Returns Promise<Record<number, Tunnel>>

      A dictionary of Tunnel objects which are keyed by the container port.

    • Returns a running Sandbox object from an ID.

      Parameters

      • sandboxId: string

      Returns Promise<Sandbox>

      Sandbox with ID

    • Get a running Sandbox by name from a deployed App.

      Raises a NotFoundError if no running Sandbox is found with the given name. A Sandbox's name is the name argument passed to App.createSandbox.

      Parameters

      • appName: string

        Name of the deployed App

      • name: string

        Name of the Sandbox

      • Optionalenvironment: string

        Optional override for the environment

      Returns Promise<Sandbox>

      Promise that resolves to a Sandbox

    • List all Sandboxes for the current Environment or App ID (if specified). If tags are specified, only Sandboxes that have at least those tags are returned.

      Parameters

      Returns AsyncGenerator<Sandbox, void, unknown>