Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sandbox/sdk/python/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from porter_sandbox import (
NotFoundError,
RateLimitError,
SandboxError,
SandboxTimeoutError,
ServerError,
)
```
Expand All @@ -24,6 +25,7 @@ from porter_sandbox import (
| `NotFoundError` | A sandbox, volume, or other resource cannot be found. |
| `RateLimitError` | The API returns a rate limit response. |
| `ServerError` | The API returns a server-side error. |
| `SandboxTimeoutError` | A request exceeds its timeout. Never retried, since the server may still be executing the request. |

Each `SandboxError` includes:

Expand Down
17 changes: 16 additions & 1 deletion sandbox/sdk/python/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,25 @@ sandbox.terminate()
| Method | Description |
| ------ | ----------- |
| `refresh()` | Refetches status and updates `phase` and `tags`. |
| `exec(command)` | Runs a command in the sandbox and returns stdout, stderr, and exit code. |
| `exec(command, timeout=None)` | Runs a command in the sandbox and returns stdout, stderr, and exit code. |
| `logs(since=None, limit=None)` | Fetches structured log lines. |
| `terminate()` | Terminates the sandbox. |

### `exec` timeouts

`exec` is long-running: the client sends no timeout by default, so the call waits for the command to exit. Pass `timeout` (seconds) to cap how long the client waits. When the timeout elapses, the SDK raises `SandboxTimeoutError` and does not retry, since the command may still be running server-side.

```python
from porter_sandbox import SandboxTimeoutError

try:
result = sandbox.exec(["sleep", "120"], timeout=30.0)
except SandboxTimeoutError:
print("exec exceeded 30s; the command may still be running in the sandbox")
```

The client-wide `timeout` on `Porter` still applies to every other request (30 seconds by default).

## Volumes

Volumes are persistent storage that can be mounted into sandboxes.
Expand Down
2 changes: 2 additions & 0 deletions sandbox/sdk/typescript/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NotFoundError,
RateLimitError,
SandboxError,
SandboxTimeoutError,
ServerError,
} from "porter-sandbox";
```
Expand All @@ -24,6 +25,7 @@ import {
| `NotFoundError` | A sandbox, volume, or other resource cannot be found. |
| `RateLimitError` | The API returns a rate limit response. |
| `ServerError` | The API returns a server-side error. |
| `SandboxTimeoutError` | A request exceeds its timeout. Never retried, since the server may still be executing the request. |

Each `SandboxError` includes:

Expand Down
22 changes: 21 additions & 1 deletion sandbox/sdk/typescript/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,30 @@ await sandbox.terminate();
| Method | Description |
| ------ | ----------- |
| `refresh()` | Refetches status and updates `phase` and `tags`. |
| `exec(command)` | Runs a command in the sandbox and returns stdout, stderr, and exit code. |
| `exec(command, requestOptions?)` | Runs a command in the sandbox and returns stdout, stderr, and exit code. |
| `logs(options?)` | Fetches structured log lines. |
| `terminate()` | Terminates the sandbox. |

### `exec` timeouts

`exec` is long-running: the client sends no timeout by default, so the call waits for the command to exit. Pass `requestOptions.timeoutMs` to cap how long the client waits. When the timeout elapses, the SDK throws `SandboxTimeoutError` and does not retry, since the command may still be running server-side.

```typescript
import { SandboxTimeoutError } from "porter-sandbox";

try {
const result = await sandbox.exec(["sleep", "120"], { timeoutMs: 30_000 });
} catch (error) {
if (error instanceof SandboxTimeoutError) {
console.error("exec exceeded 30s; the command may still be running in the sandbox");
} else {
throw error;
}
}
```

The client-wide `timeoutMs` on `Porter` still applies to every other request (30 seconds by default).

## Volumes

Volumes are persistent storage that can be mounted into sandboxes.
Expand Down