Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix process handle throw

Tomas Valenta59c864c99fad
diff --git a/packages/js-sdk/src/sandbox/process/processHandle.ts b/packages/js-sdk/src/sandbox/process/processHandle.ts
index 55c53f69b..ca6a96ce5 100644
--- a/packages/js-sdk/src/sandbox/process/processHandle.ts
+++ b/packages/js-sdk/src/sandbox/process/processHandle.ts
@@ -80,7 +80,13 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
}
async wait() {
- return this._wait
+ const result = await this._wait
+
+ if (result.exitCode !== 0) {
+ throw new ProcessExitError(result)
+ }
+
+ return result
}
async disconnect() {
@@ -88,7 +94,6 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
}
async kill() {
- await this.disconnect()
await this.handleKill()
}
@@ -149,10 +154,6 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
throw new SandboxError('Process exited without a result')
}
- if (this.result.exitCode !== 0) {
- throw new ProcessExitError(this.result)
- }
-
return this.result
}
}