diff --git a/.changeset/fix-gethost-example-command.md b/.changeset/fix-gethost-example-command.md new file mode 100644 index 0000000000..e2c2f8c556 --- /dev/null +++ b/.changeset/fix-gethost-example-command.md @@ -0,0 +1,5 @@ +--- +"e2b": patch +--- + +Fix the `Sandbox.getHost()` documentation example so it can be copy-pasted. The `@example` called `sandbox.commands.exec(...)`, which is not a method on the `Commands` class (it exposes `run`), so running the snippet threw `TypeError: sandbox.commands.exec is not a function`. It now uses `sandbox.commands.run(..., { background: true })`, allowing the long-running HTTP server to start before the example calls `getHost()`. Documentation only, no behavior change. diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts index 56caea6300..41b233043b 100644 --- a/packages/js-sdk/src/sandbox/index.ts +++ b/packages/js-sdk/src/sandbox/index.ts @@ -425,7 +425,7 @@ export class Sandbox extends SandboxApi { * ```ts * const sandbox = await Sandbox.create() * // Start an HTTP server - * await sandbox.commands.exec('python3 -m http.server 3000') + * await sandbox.commands.run('python3 -m http.server 3000', { background: true }) * // Get the hostname of the HTTP server * const serverURL = sandbox.getHost(3000) * ```