From c1b12655faf737904b953acf1e20f9ea85a8cb3f Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Sun, 5 Jul 2026 02:49:44 +0530 Subject: [PATCH] fix(js-sdk): use commands.run in Sandbox.getHost() example The getHost() JSDoc @example called sandbox.commands.exec(), which is not a method on the Commands class. Switch it to sandbox.commands.run(..., { background: true }) so the long-running HTTP server starts before getHost() is called. Documentation only, no behavior change. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> --- .changeset/fix-gethost-example-command.md | 5 +++++ packages/js-sdk/src/sandbox/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-gethost-example-command.md 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) * ```