Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix e2b sbx logs -f <id> not following (#930)

Jonas Scholzad4b882bff58
diff --git a/.changeset/forty-turtles-visit.md b/.changeset/forty-turtles-visit.md
new file mode 100644
index 000000000..3e404b085
--- /dev/null
+++ b/.changeset/forty-turtles-visit.md
@@ -0,0 +1,5 @@
+---
+'@e2b/cli': patch
+---
+
+fix sbx logs follow option
diff --git a/packages/cli/src/commands/sandbox/logs.ts b/packages/cli/src/commands/sandbox/logs.ts
index 85b74ef15..eac6741e5 100644
--- a/packages/cli/src/commands/sandbox/logs.ts
+++ b/packages/cli/src/commands/sandbox/logs.ts
@@ -103,8 +103,6 @@ export const logsCommand = new commander.Command('logs')
console.log(`\nLogs for sandbox ${asBold(sandboxID)}:`)
}
- const isRunningPromise = isRunning(sandboxID)
-
do {
const logs = await listSandboxLogs({ sandboxID, start })
@@ -123,9 +121,9 @@ export const logsCommand = new commander.Command('logs')
)
}
- const isRunning = await isRunningPromise
+ const isSandboxRunning = await isRunning(sandboxID)
- if (!isRunning && logs.length === 0 && isFirstRun) {
+ if (!isSandboxRunning && logs.length === 0 && isFirstRun) {
if (format === Format.PRETTY) {
console.log(
`\nStopped printing logs — sandbox ${withUnderline(
@@ -136,7 +134,7 @@ export const logsCommand = new commander.Command('logs')
break
}
- if (!isRunning) {
+ if (!isSandboxRunning) {
if (format === Format.PRETTY) {
console.log(
`\nStopped printing logs — sandbox is ${withUnderline(
diff --git a/packages/cli/src/commands/sandbox/utils.ts b/packages/cli/src/commands/sandbox/utils.ts
index 8bc65bcee..42c67ee7d 100644
--- a/packages/cli/src/commands/sandbox/utils.ts
+++ b/packages/cli/src/commands/sandbox/utils.ts
@@ -1,6 +1,7 @@
import { wait } from '../../utils/wait'
import { asBold } from '../../utils/format'
import { Sandbox } from 'e2b'
+import { ensureAPIKey } from 'src/api'
export function formatEnum(e: { [key: string]: string }) {
return Object.values(e)
@@ -51,7 +52,10 @@ export function getShortID(sandboxID: string) {
export async function isRunning(sandboxID: string) {
try {
- const info = await Sandbox.getInfo(getShortID(sandboxID))
+ const apiKey = ensureAPIKey()
+ const info = await Sandbox.getInfo(getShortID(sandboxID), {
+ apiKey,
+ })
return info.state === 'running'
} catch {
return false