Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

fix(js-sdk): use commands.run in Sandbox.getHost() example (#1531) (#1550)

Mish Ushakov5e141a765ff1
diff --git a/.changeset/fix-gethost-example-command.md b/.changeset/fix-gethost-example-command.md
new file mode 100644
index 000000000..e2c2f8c55
--- /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 e3133c9c9..5bc8ec529 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -511,7 +511,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)
* ```