# Traces

> Find failed or slow Sandbox operations alongside the other steps in a function run.

Open the function trace to find which Sandbox operation slowed or failed a job. Each `step.sandbox` call is a durable step: Inngest records its result for replay and applies that operation’s retry classification. Guest commands and files still have their own lifecycle.

## What appears in the trace

Open the function run in the Inngest dashboard or Dev Server. The trace shows the steps alongside the rest of the function. Select a step to inspect its timing, input, output, error details, and retry attempts.

Each command is one row, tagged with `[$]` and named after the command it ran . Sandbox operations such as creating or destroying show as plain names, like "Create sandbox":

Expand a command row and select its step to see what ran. Its Metadata tab shows the command, exit code, and Sandbox, and the header shows its timing. With `commands.run`, a nonzero exit code is a result, so the step still completes. A `$` command fails its step on one unless `exitCodes` allows it:

Give each Sandbox operation a stable, descriptive step ID. For example, `create-sandbox`, `run-command`, and `destroy-sandbox` make the sequence readable and let you identify the operation that failed. A retry appears as another attempt for that step. Completed steps return their recorded results when the function replays.

Each step carries `inngest.sandbox` metadata that names the action and the machine, command, process, or snapshot involved. A snapshot shows as one group, "Create snapshot" and "Wait for snapshot". `group.sandbox()`, `step.sandbox.python`, and `step.sandbox.typescript` show the Sandbox's whole lifetime as one group, with the create, run, and destroy steps inside. Each [tool](/docs-markdown/sandboxes/features/tools) call is its own step.

A trace records the durable API operations. It does not make the Sandbox guest process, filesystem, or output durable.

## Try it in a function

The example uses the TypeScript v4 beta API. Configure `sandboxMiddleware()`, use an account on Pro or above, and set `INNGEST_SIGNING_KEY` before running the example.

```typescript {{ title: "TypeScript" }}
const sandbox = await step.sandbox.create("create-sandbox", {
  name: `trace-${event.data.jobId}`,
  vcpu: 1,
  memoryMb: 1024,
});

const result = await sandbox.commands.run(
  "run-command",
  "printf 'hello from the sandbox\\n'",
  { timeout: "30s" },
);

await sandbox.destroy("destroy-sandbox");

return {
  sandboxId: sandbox.id,
  exitCode: result.exitCode,
  stdout: result.stdout,
};
```

After the run, open its trace and follow the three step IDs. Select `run-command` to inspect the step result or an error. Select the run to inspect the function's returned Sandbox ID and command result. A command that exits with a nonzero code still returns a command result; it does not throw solely because of that exit code.

The example destroys the Sandbox on the successful path. For a function that can fail permanently, add an `onFailure` cleanup strategy. A JavaScript `finally` block around durable steps does not guarantee cleanup after permanent failure or cancellation. See [Managed lifecycle](/docs-markdown/sandboxes/features/managed-lifecycle).

## When calls do not become durable steps

`inngest.sandboxes` makes immediate server-side requests. It does not memoize each operation as a step or add a separate step to the run trace. Use `step.sandbox` when the operation belongs to a durable function run. Use the direct client for immediate calls, live streams, or file transfer.

## Protect trace data

The trace view displays step inputs, outputs, and errors. Environment values you pass to `step.sandbox` calls (`create`, `commands.run`, `processes.start`) are not recorded: the trace keeps only the variable names . Command strings, captured output, and returned values are recorded as they are, so keep credentials out of them. The beta can inject selected workspace secrets into the Sandbox environment, but it does not automatically redact values printed to command output or files.